-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Separate binding-specific code from template stamp. Expose override points #4432
Conversation
lib/mixins/template-stamp.html
Outdated
// since a template may be re-used, memo-ize notes. | ||
if (!content._notes) { | ||
let notes = content._notes = []; | ||
notes.ownerDocument = ownerDocument || template.ownerDocument; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May not be worth threading this through since it's only used for inertness.
lib/mixins/template-stamp.html
Outdated
return content._notes; | ||
} | ||
|
||
// add annotations gleaned from subtree at `node` to `notes` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add docs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps (node, note, notes)
lib/mixins/template-stamp.html
Outdated
let noted; | ||
if (node.localName == 'template' && | ||
!node.hasAttribute('preserve-content')) { | ||
noted |= this._parseTemplate(node, note); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
noted = this._parseTemplate(node, note) || noted
lib/mixins/template-stamp.html
Outdated
!node.hasAttribute('preserve-content')) { | ||
noted |= this._parseTemplate(node, note); | ||
} else if (node.localName === 'slot') { | ||
node._hasInsertionPoint = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add note that this is a Shady DOM optimziation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be note.notes._hasInsertionPoints = true
lib/mixins/template-stamp.html
Outdated
if (node.firstChild) { | ||
noted |= this._parseTemplateChildNodes(node, note); | ||
} | ||
if (node.attributes) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use hasAttributes
lib/mixins/template-stamp.html
Outdated
if (note.notes.stripWhiteSpace && !node.textContent.trim()) { | ||
root.removeChild(node); | ||
// decrement index since node is removed | ||
i--; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems like this can just continue
and remove the if (node.parentNode)
check below
lib/mixins/template-stamp.html
Outdated
// children and avoids a bug in Chrome where nested template children | ||
// upgrade) | ||
static _parseTemplate(node, note) { | ||
let content = node.content.ownerDocument.createDocumentFragment(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this and just have 1 inert document?
lib/mixins/template-stamp.html
Outdated
static _parseTemplateNodeAttributes(node, note) { | ||
// Make copy of original attribute list, since the order may change | ||
// as attributes are added and removed | ||
let attrs = Array.prototype.slice.call(node.attributes); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Array.from
lib/mixins/property-effects.html
Outdated
name = propertyName; | ||
} | ||
note.bindings = note.bindings || []; | ||
note.bindings.push({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
es6-ify
lib/mixins/property-effects.html
Outdated
// m[1]: '{{' '[[' | ||
// m[2]: '' '!' | ||
// m[3]: 'prop' 'compute(foo,bar)' | ||
while ((m = bindingRegex.exec(text)) !== null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove !== null
Consider:
|
lib/mixins/template-stamp.html
Outdated
// (this is both an optimization to avoid re-stamping nested template | ||
// children and avoids a bug in Chrome where nested template children | ||
// upgrade) | ||
static _parseTemplateNestedContent(node, outerTemplateInfo, nodeInfo) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worth trying to collapse with _parseTemplate
? Seems like if there's an outerTemplate, you can do this content stripping.
function applyTemplateContent(inst, node, note) { | ||
if (note.templateContent) { | ||
node._content = note.templateContent; | ||
function applyTemplateContent(inst, node, nodeInfo) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change argument node
-> template
No description provided.