Skip to content

Commit

Permalink
Merge pull request #2 from PolymerLabs/fix-annote
Browse files Browse the repository at this point in the history
minimal repair to annotation system to account for scoping.
  • Loading branch information
Scott J. Miles committed Oct 24, 2014
2 parents 3cba62e + 7816ec2 commit 71b35de
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
10 changes: 8 additions & 2 deletions polymer/src/features/annotations.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,14 @@

// instance-time method
findAnnotatedNode: function(root, annote) {
return !annote.parent ? root :
this.findAnnotatedNode(root, annote.parent).childNodes[annote.index];
if (!annote.parent) {
return root;
}
var parent = this.findAnnotatedNode(root, annote.parent);
// enforce locality.
var nodes = (parent === this) ? parent.childNodes :
(parent.lightChildren || parent.childNodes);
return nodes[annote.index];
},

_parseTemplateNode: function(node, map) {
Expand Down
4 changes: 4 additions & 0 deletions polymer/src/features/content.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

register: function(prototype) {
var t = prototype._template;
// TODO(sorvell): is qsa is wrong here due to distribution?
// needs to be found via annotation system
prototype._useContent = Boolean(t && t.content.querySelector('content'));
},

Expand All @@ -14,6 +16,8 @@
pool.appendChild(this.firstChild);
}
this.contentPool = pool;
// capture lightChildren to help reify dom scoping.
this.lightChildren = Array.prototype.slice.call(this.contentPool.childNodes, 0);
},

distributeContent: function() {
Expand Down
3 changes: 2 additions & 1 deletion polymer/src/features/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
},

_stampTemplate: function(template, target) {
// TODO(sorvell): light dom children will invalidate annotations.
target.insertBefore(this.instanceTemplate(template),
target.firstElementChild);
},
Expand All @@ -40,4 +41,4 @@

});

</script>
</script>

0 comments on commit 71b35de

Please sign in to comment.