-
-
Notifications
You must be signed in to change notification settings - Fork 4.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
Port attributeBindings to AttrNode views #10186
Conversation
200350a
to
e1375f3
Compare
@@ -553,7 +553,6 @@ test('should not reset cursor position when text field receives keyUp event', fu | |||
|
|||
appendView(view); | |||
|
|||
view.$().val('Brosiedoon, King of the Brocean'); |
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.
The old logic for writing a value
would compare the value to be set against the one currently in the DOM.
In the new logic, a cached last value is compared instead. The bound attribute does not want a 3rd party (here, a jQuery call) to change the properties.
We may need to fall back to the check-dom-every-time strategy if this is problematic.
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.
I much prefer the new logic of caching the last value. IMHO, it has been fairly clear thst third parties changing the DOM underneath is not acceptable. It may have worked in this particular instance, but many many others did not.
This looks wonderful! |
HTMLBars v0.8.1 includes the upstream HTMLBars changes needed for this. |
cebe456
to
c32d9c3
Compare
09b7fc5
to
d06d108
Compare
binding = attributeBindings[i]; | ||
split = binding.split(':'); | ||
property = split[0]; | ||
attrName = split[1] || property; |
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.
attrName
should be the full name in case of namespaced attributes, rather than split[1]
. I believe that would take care of #9298.
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.
Oof this is for micro-syntax not for namespaced attrs. The solution is not as super-simple as it seems, imo.
isDisabled:disabled
is a mapping ofview-prop:attr
xlink:href
is a namespaced attrhrefLink:xlink:href
is a mapping ofview-prop:namespaced-attr
There isn't really a way to support all that. I would propose:
isDisabled:disabled
is a mapping ofview-prop:attr
xlink:href
is a mapping ofview-prop:attr
(gotcha)hrefLink:xlink:href
is a mapping ofview-prop:namespaced-attr
This would be consistent. Basically, the micro-syntax sucks. Maybe we can drop it in 2.0. I don't want to tackle it here though.
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.
Good thinking! Since :
isn't valid a valid character for property names, they'd have to use a view-prop anyway, right? In that case the gotcha's not much of a limitation, since there's no way they could define the property for xlink:href
under its own name even if they wanted to. (If I remember the whole mapping thing right, that is)
d06d108
to
141571d
Compare
Opened an upstream PR at tildeio/htmlbars#253, and an issue at tildeio/htmlbars#251 that needs a PR. IE10 is a go, still have two or three IE9 issues. |
141571d
to
4a30267
Compare
IE9 is a go. PR opened for tildeio/htmlbars#256. I need to wait on IE8 until HTMLBars is working again. |
4a30267
to
0f6d58b
Compare
Getting close. IE9 and up are 100% with htmlbars master. Just IE8. |
I'm comfortable landing this for current master (which will branch to 1.11 shortly), but I think @mixonic is waiting to review and confirm that this general strategy will work for IE8. |
ping @mixonic - have any updates here? |
e27cafb
to
a4d4a90
Compare
Rebased this tonight. Something in IE8 on master causes the page to crash then reload. I'm blocked on that now. Unless someone else wants to hop on it first, some IE things we should do before trying to fix 8:
I'll be working on some of this over the weekend. |
a4d4a90
to
79588e0
Compare
79588e0
to
049ac2a
Compare
Needs tildeio/htmlbars#276 to land for node tests to pass |
cbdf7fc
to
04ce7a1
Compare
This is good implementation-wise. Performance benchmarks stand unchanged against master itself (tested with render list, render list with link-to, and render link-to). I believe this is good to go. |
04ce7a1
to
c352922
Compare
I swear this is a net lines-of-code win, just need to wait until we strip the |
Port attributeBindings to AttrNode views
Awesome! Since this is merged now, I could do a PR to implement #10186 (comment). |
Turns out this definitely breaks container view. But also there are no tests in all of Ember that use attribute bindings and container view so meeeeh. Working on the classNameBindings patch this weekend, and will make part of that porting the attr nodes onto |
Ember's attribute bindings were a custom system based on the buffer and a view. The buffer would be updated with initial values, and the element have those attributes applied during it's own render pass. Observers were attached to watch changing values.
This refactors attribute bindings to use AttrNode objects, which in turn are rendered like a normal view on the renderer. They have access to morphs and the
domHelper
in a standard view-ish way.TODO
type
needs to be added to the buffer in a legacy string style. I've kept this in mind an not gutted the legacy system, so it should go fairly smoothly.parseHTML
Allow numbers to be parsed as HTML in IE tildeio/htmlbars#253/cc @mmun @krisselden and view-layer crew.
Closes #9921