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

Commit

Permalink
Merge pull request #423 from arv/new-shadow-dom
Browse files Browse the repository at this point in the history
Bring shadow dom algorithms up to date
  • Loading branch information
dfreedm committed Apr 24, 2014
2 parents 640ac89 + e059572 commit 180af95
Show file tree
Hide file tree
Showing 14 changed files with 590 additions and 533 deletions.
489 changes: 232 additions & 257 deletions src/ShadowRenderer.js

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions src/TreeScope.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,21 @@
* A tree scope represents the root of a tree. All nodes in a tree point to
* the same TreeScope object. The tree scope of a node get set the first time
* it is accessed or when a node is added or remove to a tree.
*
* The root is a Node that has no parent.
*
* The parent is another TreeScope. For ShadowRoots, it is the TreeScope of
* the host of the ShadowRoot.
*
* @param {!Node} root
* @param {TreeScope} parent
* @constructor
*/
function TreeScope(root, parent) {
/** @type {!Node} */
this.root = root;

/** @type {TreeScope} */
this.parent = parent;
}

Expand Down Expand Up @@ -48,6 +59,10 @@
}

function getTreeScope(node) {
if (node instanceof scope.wrappers.Window) {
debugger;
}

if (node.treeScope_)
return node.treeScope_;
var parent = node.parentNode;
Expand Down
4 changes: 4 additions & 0 deletions src/wrappers/Document.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,10 @@
new DOMImplementation(unwrap(this).implementation);
implementationTable.set(this, implementation);
return implementation;
},

get defaultView() {
return wrap(unwrap(this).defaultView);
}
});

Expand Down
2 changes: 2 additions & 0 deletions src/wrappers/Element.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@
return this.impl.polymerShadowRoot_ || null;
},

// getDestinationInsertionPoints added in ShadowRenderer.js

setAttribute: function(name, value) {
var oldValue = this.impl.getAttribute(name);
this.impl.setAttribute(name, value);
Expand Down
2 changes: 0 additions & 2 deletions src/wrappers/HTMLContentElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
}

// getDistributedNodes is added in ShadowRenderer

// TODO: attribute boolean resetStyleInheritance;
});

if (OriginalHTMLContentElement)
Expand Down
6 changes: 3 additions & 3 deletions src/wrappers/HTMLShadowElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

var HTMLElement = scope.wrappers.HTMLElement;
var mixin = scope.mixin;
var NodeList = scope.wrappers.NodeList;
var registerWrapper = scope.registerWrapper;

var OriginalHTMLShadowElement = window.HTMLShadowElement;
Expand All @@ -15,9 +16,8 @@
HTMLElement.call(this, node);
}
HTMLShadowElement.prototype = Object.create(HTMLElement.prototype);
mixin(HTMLShadowElement.prototype, {
// TODO: attribute boolean resetStyleInheritance;
});

// getDistributedNodes is added in ShadowRenderer

if (OriginalHTMLShadowElement)
registerWrapper(OriginalHTMLShadowElement, HTMLShadowElement);
Expand Down
6 changes: 5 additions & 1 deletion src/wrappers/Window.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,13 @@
renderAllPending();
return new Selection(originalGetSelection.call(unwrap(this)));
},

get document() {
return wrap(unwrap(this).document);
}
});

registerWrapper(OriginalWindow, Window);
registerWrapper(OriginalWindow, Window, window);

scope.wrappers.Window = Window;

Expand Down
Loading

0 comments on commit 180af95

Please sign in to comment.