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

Commit

Permalink
The older shadow root should act as a parent tree scope
Browse files Browse the repository at this point in the history
  • Loading branch information
arv committed Apr 18, 2014
1 parent 9513e0c commit 769c74c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/wrappers/ShadowRoot.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@
// DocumentFragment instance. Override that.
rewrap(node, this);

this.treeScope_ = new TreeScope(this, getTreeScope(hostWrapper));

var oldShadowRoot = hostWrapper.shadowRoot;
nextOlderShadowTreeTable.set(this, oldShadowRoot);

this.treeScope_ =
new TreeScope(this, getTreeScope(oldShadowRoot || hostWrapper));

shadowHostTable.set(this, hostWrapper);
}
ShadowRoot.prototype = Object.create(DocumentFragment.prototype);
Expand Down
2 changes: 1 addition & 1 deletion test/js/TreeScope.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ suite('TreeScope', function() {
assert.equal(ts1.parent, null);
assert.equal(ts2.parent, ts1);
assert.equal(ts3.parent, ts2);
assert.equal(ts4.parent, ts1);
assert.equal(ts4.parent, ts2);

var div2 = document.createElement('div');
div2.appendChild(a);
Expand Down

2 comments on commit 769c74c

@jmesserly
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm, I wonder if there's a bug here. On line 83 the test case was not updated. It seems like the correct result there would be "ts2"? In other words, I don't think the fix works in the case where a node is moved from one tree to another. In that case, the youngest ShadowRoot gets updated to have its TreeScope be the host node's tree scope.

My guess is that an additional fix is needed to reconcile with this earlier commit: ce71c44

@jmesserly
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.