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

Commit 180af95

Browse files
committed
Merge pull request #423 from arv/new-shadow-dom
Bring shadow dom algorithms up to date
2 parents 640ac89 + e059572 commit 180af95

14 files changed

+590
-533
lines changed

src/ShadowRenderer.js

+232-257
Large diffs are not rendered by default.

src/TreeScope.js

+15
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,21 @@
1111
* A tree scope represents the root of a tree. All nodes in a tree point to
1212
* the same TreeScope object. The tree scope of a node get set the first time
1313
* it is accessed or when a node is added or remove to a tree.
14+
*
15+
* The root is a Node that has no parent.
16+
*
17+
* The parent is another TreeScope. For ShadowRoots, it is the TreeScope of
18+
* the host of the ShadowRoot.
19+
*
20+
* @param {!Node} root
21+
* @param {TreeScope} parent
1422
* @constructor
1523
*/
1624
function TreeScope(root, parent) {
25+
/** @type {!Node} */
1726
this.root = root;
27+
28+
/** @type {TreeScope} */
1829
this.parent = parent;
1930
}
2031

@@ -48,6 +59,10 @@
4859
}
4960

5061
function getTreeScope(node) {
62+
if (node instanceof scope.wrappers.Window) {
63+
debugger;
64+
}
65+
5166
if (node.treeScope_)
5267
return node.treeScope_;
5368
var parent = node.parentNode;

src/wrappers/Document.js

+4
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,10 @@
264264
new DOMImplementation(unwrap(this).implementation);
265265
implementationTable.set(this, implementation);
266266
return implementation;
267+
},
268+
269+
get defaultView() {
270+
return wrap(unwrap(this).defaultView);
267271
}
268272
});
269273

src/wrappers/Element.js

+2
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@
7373
return this.impl.polymerShadowRoot_ || null;
7474
},
7575

76+
// getDestinationInsertionPoints added in ShadowRenderer.js
77+
7678
setAttribute: function(name, value) {
7779
var oldValue = this.impl.getAttribute(name);
7880
this.impl.setAttribute(name, value);

src/wrappers/HTMLContentElement.js

-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@
3030
}
3131

3232
// getDistributedNodes is added in ShadowRenderer
33-
34-
// TODO: attribute boolean resetStyleInheritance;
3533
});
3634

3735
if (OriginalHTMLContentElement)

src/wrappers/HTMLShadowElement.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
var HTMLElement = scope.wrappers.HTMLElement;
99
var mixin = scope.mixin;
10+
var NodeList = scope.wrappers.NodeList;
1011
var registerWrapper = scope.registerWrapper;
1112

1213
var OriginalHTMLShadowElement = window.HTMLShadowElement;
@@ -15,9 +16,8 @@
1516
HTMLElement.call(this, node);
1617
}
1718
HTMLShadowElement.prototype = Object.create(HTMLElement.prototype);
18-
mixin(HTMLShadowElement.prototype, {
19-
// TODO: attribute boolean resetStyleInheritance;
20-
});
19+
20+
// getDistributedNodes is added in ShadowRenderer
2121

2222
if (OriginalHTMLShadowElement)
2323
registerWrapper(OriginalHTMLShadowElement, HTMLShadowElement);

src/wrappers/Window.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,13 @@
5656
renderAllPending();
5757
return new Selection(originalGetSelection.call(unwrap(this)));
5858
},
59+
60+
get document() {
61+
return wrap(unwrap(this).document);
62+
}
5963
});
6064

61-
registerWrapper(OriginalWindow, Window);
65+
registerWrapper(OriginalWindow, Window, window);
6266

6367
scope.wrappers.Window = Window;
6468

0 commit comments

Comments
 (0)