@@ -320,58 +320,56 @@ describe('react-draggable', function () {
320
320
assert ( transform . indexOf ( 'translate(100,100)' ) >= 0 ) ;
321
321
} ) ;
322
322
323
- it ( 'should add and remove user-select styles' , function ( ) {
324
- const userSelectStyleStr = `${ userSelectStyle } : none;` ;
325
-
326
- drag = TestUtils . renderIntoDocument (
327
- < Draggable >
328
- < div />
329
- </ Draggable >
330
- ) ;
331
-
332
- const node = ReactDOM . findDOMNode ( drag ) ;
333
-
334
- assert ( ! document . body . getAttribute ( 'style' ) ) ;
335
- TestUtils . Simulate . mouseDown ( node , { clientX : 0 , clientY : 0 } ) ;
336
- assert ( document . body . getAttribute ( 'style' ) . indexOf ( userSelectStyleStr ) !== - 1 ) ;
337
- TestUtils . Simulate . mouseUp ( node ) ;
338
- assert ( ! document . body . getAttribute ( 'style' ) ) ;
339
- } ) ;
340
-
341
- it ( 'should not add and remove user-select styles when disabled' , function ( ) {
342
-
343
- drag = TestUtils . renderIntoDocument (
344
- < Draggable enableUserSelectHack = { false } >
345
- < div />
346
- </ Draggable >
347
- ) ;
348
-
349
- const node = ReactDOM . findDOMNode ( drag ) ;
350
-
351
- assert ( ! document . body . getAttribute ( 'style' ) ) ;
352
- TestUtils . Simulate . mouseDown ( node , { clientX : 0 , clientY : 0 } ) ;
353
- assert ( ! document . body . getAttribute ( 'style' ) ) ;
354
- TestUtils . Simulate . mouseUp ( node ) ;
355
- assert ( ! document . body . getAttribute ( 'style' ) ) ;
356
- } ) ;
357
-
358
- it ( 'should not add and remove user-select styles when onStart returns false' , function ( ) {
359
- function onStart ( ) { return false ; }
360
-
361
- drag = TestUtils . renderIntoDocument (
362
- < Draggable onStart = { onStart } >
363
- < div />
364
- </ Draggable >
365
- ) ;
366
-
367
- const node = ReactDOM . findDOMNode ( drag ) ;
368
-
369
- assert ( ! document . body . getAttribute ( 'style' ) ) ;
370
- TestUtils . Simulate . mouseDown ( node , { clientX : 0 , clientY : 0 } ) ;
371
- assert ( ! document . body . getAttribute ( 'style' ) ) ;
372
- TestUtils . Simulate . mouseUp ( node ) ;
373
- assert ( ! document . body . getAttribute ( 'style' ) ) ;
374
- } ) ;
323
+ it ( 'should add and remove transparent selection class' , function ( ) {
324
+ drag = TestUtils . renderIntoDocument (
325
+ < Draggable >
326
+ < div />
327
+ </ Draggable >
328
+ ) ;
329
+
330
+ const node = ReactDOM . findDOMNode ( drag ) ;
331
+
332
+ assert ( ! document . body . classList . contains ( 'react-draggable-transparent-selection' ) ) ;
333
+ TestUtils . Simulate . mouseDown ( node , { clientX : 0 , clientY : 0 } ) ;
334
+ assert ( document . body . classList . contains ( 'react-draggable-transparent-selection' ) ) ;
335
+ TestUtils . Simulate . mouseUp ( node ) ;
336
+ assert ( ! document . body . classList . contains ( 'react-draggable-transparent-selection' ) ) ;
337
+ } ) ;
338
+
339
+ it ( 'should not add and remove transparent selection class when disabled' , function ( ) {
340
+
341
+ drag = TestUtils . renderIntoDocument (
342
+ < Draggable enableUserSelectHack = { false } >
343
+ < div />
344
+ </ Draggable >
345
+ ) ;
346
+
347
+ const node = ReactDOM . findDOMNode ( drag ) ;
348
+
349
+ assert ( ! document . body . classList . contains ( 'react-draggable-transparent-selection' ) ) ;
350
+ TestUtils . Simulate . mouseDown ( node , { clientX : 0 , clientY : 0 } ) ;
351
+ assert ( ! document . body . classList . contains ( 'react-draggable-transparent-selection' ) ) ;
352
+ TestUtils . Simulate . mouseUp ( node ) ;
353
+ assert ( ! document . body . classList . contains ( 'react-draggable-transparent-selection' ) ) ;
354
+ } ) ;
355
+
356
+ it ( 'should not add and remove transparent selection class when onStart returns false' , function ( ) {
357
+ function onStart ( ) { return false ; }
358
+
359
+ drag = TestUtils . renderIntoDocument (
360
+ < Draggable onStart = { onStart } >
361
+ < div />
362
+ </ Draggable >
363
+ ) ;
364
+
365
+ const node = ReactDOM . findDOMNode ( drag ) ;
366
+
367
+ assert ( ! document . body . classList . contains ( 'react-draggable-transparent-selection' ) ) ;
368
+ TestUtils . Simulate . mouseDown ( node , { clientX : 0 , clientY : 0 } ) ;
369
+ assert ( ! document . body . classList . contains ( 'react-draggable-transparent-selection' ) ) ;
370
+ TestUtils . Simulate . mouseUp ( node ) ;
371
+ assert ( ! document . body . classList . contains ( 'react-draggable-transparent-selection' ) ) ;
372
+ } ) ;
375
373
376
374
it ( 'should be draggable when in an iframe' , function ( done ) {
377
375
let dragged = false ;
@@ -397,35 +395,32 @@ describe('react-draggable', function () {
397
395
} , 50 ) ;
398
396
} ) ;
399
397
400
- it ( 'should add and remove user-select styles to iframe’s body when in an iframe' , function ( done ) {
401
- const userSelectStyleStr = `${ userSelectStyle } : none;` ;
402
-
403
- const dragElement = (
404
- < Draggable >
405
- < div />
406
- </ Draggable >
407
- ) ;
408
- const renderRoot = document . body . appendChild ( document . createElement ( 'div' ) ) ;
409
- const frame = ReactDOM . render ( < FrameComponent > { dragElement } </ FrameComponent > , renderRoot ) ;
410
-
411
- setTimeout ( ( ) => {
412
- const iframeDoc = ReactDOM . findDOMNode ( frame ) . contentDocument ;
413
- const node = iframeDoc . querySelector ( '.react-draggable' ) ;
414
- iframeDoc . body . setAttribute ( 'style' , '' ) ;
415
-
416
- assert ( ! iframeDoc . body . getAttribute ( 'style' ) ) ;
417
- assert ( ! document . body . getAttribute ( 'style' ) ) ;
418
- TestUtils . Simulate . mouseDown ( node , { clientX : 0 , clientY : 0 } ) ;
419
- assert ( iframeDoc . body . getAttribute ( 'style' ) . indexOf ( userSelectStyleStr ) !== - 1 ) ;
420
- assert ( ! document . body . getAttribute ( 'style' ) ) ;
421
- TestUtils . Simulate . mouseUp ( node ) ;
422
- assert ( ! iframeDoc . body . getAttribute ( 'style' ) ) ;
423
- assert ( ! document . body . getAttribute ( 'style' ) ) ;
424
-
425
- renderRoot . parentNode . removeChild ( renderRoot ) ;
426
- done ( ) ;
427
- } , 50 ) ;
428
- } ) ;
398
+ it ( 'should add and remove transparent selection class to iframe’s body when in an iframe' , function ( done ) {
399
+ const dragElement = (
400
+ < Draggable >
401
+ < div />
402
+ </ Draggable >
403
+ ) ;
404
+ const renderRoot = document . body . appendChild ( document . createElement ( 'div' ) ) ;
405
+ const frame = ReactDOM . render ( < FrameComponent > { dragElement } </ FrameComponent > , renderRoot ) ;
406
+
407
+ setTimeout ( ( ) => {
408
+ const iframeDoc = ReactDOM . findDOMNode ( frame ) . contentDocument ;
409
+ const node = iframeDoc . querySelector ( '.react-draggable' ) ;
410
+
411
+ assert ( ! document . body . classList . contains ( 'react-draggable-transparent-selection' ) ) ;
412
+ assert ( ! iframeDoc . body . classList . contains ( 'react-draggable-transparent-selection' ) ) ;
413
+ TestUtils . Simulate . mouseDown ( node , { clientX : 0 , clientY : 0 } ) ;
414
+ assert ( ! document . body . classList . contains ( 'react-draggable-transparent-selection' ) ) ;
415
+ assert ( iframeDoc . body . classList . contains ( 'react-draggable-transparent-selection' ) ) ;
416
+ TestUtils . Simulate . mouseUp ( node ) ;
417
+ assert ( ! document . body . classList . contains ( 'react-draggable-transparent-selection' ) ) ;
418
+ assert ( ! iframeDoc . body . classList . contains ( 'react-draggable-transparent-selection' ) ) ;
419
+
420
+ renderRoot . parentNode . removeChild ( renderRoot ) ;
421
+ done ( ) ;
422
+ } , 50 ) ;
423
+ } ) ;
429
424
} ) ;
430
425
431
426
describe ( 'interaction' , function ( ) {
0 commit comments