Skip to content

Commit 9d3bbf9

Browse files
committed
IE test fixes
1 parent de6a17f commit 9d3bbf9

File tree

3 files changed

+21
-20
lines changed

3 files changed

+21
-20
lines changed

lib/utils/domFns.es6

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ export function getTouchIdentifier(e: MouseTouchEvent): ?number {
130130
const userSelectPrefix = getPrefix('user-select');
131131
const userSelect = browserPrefixToStyle('user-select', userSelectPrefix);
132132
const userSelectStyle = `;${userSelect}: none;`;
133+
const userSelectReplaceRegExp = new RegExp(`;?${userSelect}: none;`); // leading ; not present on IE
133134

134135
// Note we're passing `document` b/c we could be iframed
135136
export function addUserSelectStyles(body: HTMLElement) {
@@ -139,7 +140,7 @@ export function addUserSelectStyles(body: HTMLElement) {
139140

140141
export function removeUserSelectStyles(body: HTMLElement) {
141142
const style = body.getAttribute('style') || '';
142-
body.setAttribute('style', style.replace(userSelectStyle, ''));
143+
body.setAttribute('style', style.replace(userSelectReplaceRegExp, ''));
143144
}
144145

145146
export function styleHacks(childStyle: Object = {}): Object {

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
"browser": "dist/react-draggable.js",
77
"scripts": {
88
"test": "make test",
9-
"test-debug": "karma start --browsers=Chrome --single-run",
10-
"test-ie": "karma start --browsers=IE --single-run",
9+
"test-debug": "karma start --browsers=Chrome",
10+
"test-ie": "karma start --browsers=IE",
1111
"dev": "make dev",
1212
"build": "make clean build",
1313
"lint": "make lint"

specs/draggable.spec.jsx

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ describe('react-draggable', function () {
324324
});
325325

326326
it('should add and remove user-select styles', function () {
327-
const userSelectStyleStr = `;${userSelectStyle}: none;`;
327+
const userSelectStyleStr = `${userSelectStyle}: none;`;
328328

329329
drag = TestUtils.renderIntoDocument(
330330
<Draggable>
@@ -334,11 +334,11 @@ describe('react-draggable', function () {
334334

335335
const node = ReactDOM.findDOMNode(drag);
336336

337-
assert(document.body.getAttribute('style') === '');
337+
assert(!document.body.getAttribute('style'));
338338
TestUtils.Simulate.mouseDown(node, {clientX: 0, clientY: 0});
339-
assert(document.body.getAttribute('style') === userSelectStyleStr);
339+
assert(document.body.getAttribute('style').indexOf(userSelectStyleStr) !== -1);
340340
TestUtils.Simulate.mouseUp(node);
341-
assert(document.body.getAttribute('style') === '');
341+
assert(!document.body.getAttribute('style'));
342342
});
343343

344344
it('should not add and remove user-select styles when disabled', function () {
@@ -351,11 +351,11 @@ describe('react-draggable', function () {
351351

352352
const node = ReactDOM.findDOMNode(drag);
353353

354-
assert(document.body.getAttribute('style') === '');
354+
assert(!document.body.getAttribute('style'));
355355
TestUtils.Simulate.mouseDown(node, {clientX: 0, clientY: 0});
356-
assert(document.body.getAttribute('style') === '');
356+
assert(!document.body.getAttribute('style'));
357357
TestUtils.Simulate.mouseUp(node);
358-
assert(document.body.getAttribute('style') === '');
358+
assert(!document.body.getAttribute('style'));
359359
});
360360

361361
it('should not add and remove user-select styles when onStart returns false', function () {
@@ -369,11 +369,11 @@ describe('react-draggable', function () {
369369

370370
const node = ReactDOM.findDOMNode(drag);
371371

372-
assert(document.body.getAttribute('style') === '');
372+
assert(!document.body.getAttribute('style'));
373373
TestUtils.Simulate.mouseDown(node, {clientX: 0, clientY: 0});
374-
assert(document.body.getAttribute('style') === '');
374+
assert(!document.body.getAttribute('style'));
375375
TestUtils.Simulate.mouseUp(node);
376-
assert(document.body.getAttribute('style') === '');
376+
assert(!document.body.getAttribute('style'));
377377
});
378378

379379
it('should be draggable when in an iframe', function (done) {
@@ -401,7 +401,7 @@ describe('react-draggable', function () {
401401
});
402402

403403
it('should add and remove user-select styles to iframe’s body when in an iframe', function (done) {
404-
const userSelectStyleStr = `;${userSelectStyle}: none;`;
404+
const userSelectStyleStr = `${userSelectStyle}: none;`;
405405

406406
const dragElement = (
407407
<Draggable onDrag={function() { dragged = true; }}>
@@ -416,14 +416,14 @@ describe('react-draggable', function () {
416416
const node = iframeDoc.querySelector('.react-draggable');
417417
iframeDoc.body.setAttribute('style', '');
418418

419-
assert(iframeDoc.body.getAttribute('style') === '');
420-
assert(document.body.getAttribute('style') === '');
419+
assert(!iframeDoc.body.getAttribute('style'));
420+
assert(!document.body.getAttribute('style'));
421421
TestUtils.Simulate.mouseDown(node, {clientX: 0, clientY: 0});
422-
assert(iframeDoc.body.getAttribute('style') === userSelectStyleStr);
423-
assert(document.body.getAttribute('style') === '');
422+
assert(iframeDoc.body.getAttribute('style').indexOf(userSelectStyleStr) !== -1);
423+
assert(!document.body.getAttribute('style'));
424424
TestUtils.Simulate.mouseUp(node);
425-
assert(iframeDoc.body.getAttribute('style') === '');
426-
assert(document.body.getAttribute('style') === '');
425+
assert(!iframeDoc.body.getAttribute('style'));
426+
assert(!document.body.getAttribute('style'));
427427

428428
renderRoot.parentNode.removeChild(renderRoot);
429429
done();

0 commit comments

Comments
 (0)