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

Commit

Permalink
Corrects document.importNode, fixes #317
Browse files Browse the repository at this point in the history
  • Loading branch information
sorvell committed Nov 21, 2013
1 parent cdd61fd commit 35a1212
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/wrappers/Document.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@
doc.adoptNode(oldShadowRoot);
}

var originalImportNode = document.importNode;

mixin(Document.prototype, {
adoptNode: function(node) {
if (node.parentNode)
Expand All @@ -89,6 +91,9 @@
},
elementFromPoint: function(x, y) {
return elementFromPoint(this, this, x, y);
},
importNode: function(node, deep) {
return wrap(originalImportNode.call(this.impl, unwrap(node), deep));
}
});

Expand Down Expand Up @@ -207,6 +212,7 @@
window.HTMLDocument || window.Document, // Gecko adds these to HTMLDocument
], [
'adoptNode',
'importNode',
'contains',
'createComment',
'createDocumentFragment',
Expand Down
16 changes: 16 additions & 0 deletions test/js/Document.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,22 @@ htmlSuite('Document', function() {
assert.equal(c.ownerDocument, doc);
});

test('importNode', function() {
var doc = wrap(document);
var doc2 = doc.implementation.createHTMLDocument('');
var div = doc2.createElement('div');
div.innerHTML = 'test';
assert.equal(div.ownerDocument, doc2);

var div2 = document.importNode(div, true);
assert.equal(div.innerHTML, div2.innerHTML);
assert.equal(div2.ownerDocument, doc);

var div3 = doc2.importNode(div2);
assert.equal(div3.innerHTML, '');
assert.equal(div3.ownerDocument, doc2);
});

test('elementFromPoint', function() {
div = document.body.appendChild(document.createElement('div'));
div.style.cssText = 'position: fixed; background: green; ' +
Expand Down

0 comments on commit 35a1212

Please sign in to comment.