Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Get 100% in IE9 and IE10 #213

Merged
merged 1 commit into from
Aug 16, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/wrappers/Range.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
var unwrapIfNeeded = scope.unwrapIfNeeded;
var wrap = scope.wrap;

var OriginalRange = window.Range;

function Range(impl) {
this.impl = impl;
}
Expand Down Expand Up @@ -73,12 +75,16 @@
},
intersectsNode: function(node) {
return this.impl.intersectsNode(unwrapIfNeeded(node));
},
createContextualFragment: function(html) {
return wrap(this.impl.createContextualFragment(html));
}
};

// IE9 does not have createContextualFragment.
if (OriginalRange.prototype.createContextualFragment) {
Range.prototype.createContextualFragment = function(html) {
return wrap(this.impl.createContextualFragment(html));
};
}

registerWrapper(window.Range, Range);

scope.wrappers.Range = Range;
Expand Down
19 changes: 12 additions & 7 deletions test/js/Range.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,20 @@ suite('Range', function() {
});

test('createContextualFragment', function() {
var range = document.createRange();
var container = document.body || document.head;
// IE9 does not support createContextualFragment.
if (!Range.prototype.createContextualFragment)
return;

range.selectNode(container);
var fragment = range.createContextualFragment('<b></b>');
var range = document.createRange();
var container = document.body || document.head;

range.selectNode(container);

var fragment = range.createContextualFragment('<b></b>');

assert.instanceOf(fragment, DocumentFragment);
assert.equal(fragment.firstChild.localName, 'b');
assert.equal(fragment.childNodes.length, 1);
assert.instanceOf(fragment, DocumentFragment);
assert.equal(fragment.firstChild.localName, 'b');
assert.equal(fragment.childNodes.length, 1);
});

});
12 changes: 9 additions & 3 deletions test/js/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ suite('Shadow DOM', function() {
testRender(':checked',
'<input type=checkbox><input type=checkbox checked>',
'<content select=":checked"></content>',
/Firefox/.test(navigator.userAgent) ?
/Firefox|MSIE 9/.test(navigator.userAgent) ?
'<input checked="" type="checkbox">' :
'<input type="checkbox" checked="">');
testRender(':indeterminate',
Expand Down Expand Up @@ -321,7 +321,10 @@ suite('Shadow DOM', function() {
assert.equal(calls, 1);

a.setAttribute('id', 'a');
assert.equal(getVisualInnerHtml(host), '<a foo="bar" id="a"></a>');
var visHTML = getVisualInnerHtml(host);
// IE orders the attributes differently.
assert.isTrue(visHTML === '<a foo="bar" id="a"></a>' ||
visHTML === '<a id="a" foo="bar"></a>');
assert.equal(calls, 2);

a.removeAttribute('foo');
Expand Down Expand Up @@ -365,7 +368,10 @@ suite('Shadow DOM', function() {
assert.equal(calls, 1);

a.setAttribute('class', 'a');
assert.equal(getVisualInnerHtml(host), '<a foo="bar" class="a"></a>');
var visHTML = getVisualInnerHtml(host);
// IE orders the attributes differently.
assert.isTrue(visHTML === '<a foo="bar" class="a"></a>' ||
visHTML === '<a class="a" foo="bar"></a>');
assert.equal(calls, 2);

a.removeAttribute('foo');
Expand Down