-
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
2.0 Improvements to binding API #4510
Conversation
I am so excite! And also confuse! How can people do runtime template binding? By that do you mean identifying an instance-specific template and then calling Can you bind a template more than once? (i.e., could you mutate and re-bind the template) Can you bind multiple templates? Inquiring minds want to know... Thanks, |
this.__dataCounter++; | ||
this._propertiesChanged(this.__data, changedProps, oldProps); | ||
this.__dataCounter--; | ||
if (!this.__dataInitialized) { |
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.
Now that we have __dataInitialized
it probably makes sense to prevent _invalidateProperties
from scheduling a flush if this flag is not true.
lib/mixins/property-effects.html
Outdated
part.compoundIndex = i; | ||
for (let j=0; j<dependencies.length; j++) { | ||
let trigger = dependencies[j]; | ||
if (typeof trigger == 'string') { |
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.
Bookmark to consider if we want to assume we should parseArg
the trigger
if it's a string.
if (hasPaths && (path.length > info.value.length) && | ||
(info.kind == 'property') && !info.isCompound && | ||
node.__propertyEffects && node.__propertyEffects[info.name]) { | ||
if (hasPaths && part.source && (path.length > part.source.length) && |
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 a comment explaining why path processing is not included with _evaluateBinding
.
lib/mixins/property-effects.html
Outdated
* @protected | ||
*/ | ||
_stampBoundTemplate(template) { | ||
let dom = super._stampTemplate(template); |
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.
super
=> this
} | ||
} else { | ||
// Property or path | ||
dependencies.push(source); |
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 parseArg(source)
so it doesn't auto-wildcard.
@arthurevans You can call
Note one review comment is to change This PR (and the previously merged #4432) wasn't outright intending to add new features in the RC; the main goal here was to refactor the existing code to make the whole binding system more extensible,however the ability to stamp multiple templates sort of fell out pretty easily, so we'll probably go ahead and add this feature before the final release. Still need to add tests and address review feedback... If anything starts looking too risky we may trim this back. Will keep you in the loop. |
- Adds override points for _parseBindings and _evaluateBinding - Adds support for runtime template binding - Moves ready(), _hasAccessor tracking, and instance property swizzle at ready time to PropertyAccessors
ed30b21
to
03bed19
Compare
* PropertyAccessors must call `_flushProperties` to enable * Avoid tearing off oldProps (unnecessary) * Add `addBinding` docs * Merge notifyListeners into `setupBindings` * Add comment re: path-bindings not being overridable * Remove `dom` argument from `_bindTemplate` * Rename `_stampBoundTemplate` back to `_stampTemplate`
* Refactor `_bindTemplate` to remove problematic `hasCreatedAccessors` * Remove vestigial `dom` from `_bindTemplate` call * Rename `_unstampTemplate` to `_removeBoundDom` * Add `infoIndex` to `nodeInfo` (and renamed parent & index) * Add test to ensure runtime accessors created for new props in runtime stamped template * Changed custom binding test to use different prop names * Added test for #first count after removing bound dom
39a455e
to
d0bd96d
Compare
PropertyAccessors