-
-
Notifications
You must be signed in to change notification settings - Fork 55
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
binding behind if.binding still evaluated when if.binding removes the node #252
Comments
Question on the ordering of custom attributes. In knockoutjs, when I define a bindingHandler (similar to aurelia's custom attributes), I can specify the execution order relative to other bindingHandlers. I was expecting similar thing in aurelia but I could not find clear clue in the source code. How does aurelia makes sure repeat.for/with.bind/if.bind happen before other bindings on the same node? Are all magic controlled by bindingContext and overrideContext? |
we're working on a fix for the issue you've reported- tracking this here:
Repeat, with and if are called template controllers. They bind before other bindings. You cannot use multiple template controller attributes on the same dom element. |
Thx. Maybe the document should be clear about not using repeat/if/with on same element. I actually used repeat and if together on many occasions. By luck, they work without any problem, repeat binding is performed before if binding at least for now. This is a good default behaviour to keep, otherwise I will break the bindings to 2 levels for future proof. |
Make sure you test in multiple browsers. Some sort the attributes alphabetically, some leave them as-is. |
Thx. I fix my code to avoid undetermined behaviour. When you got time, please update doc to reflect this. |
@huochunpeng
There is actually even much better solution: use aurelia-template-lint to detect this issue and many more at build time. |
I'm submitting a bug report
1.0.0
Please tell us about your environment:
OSX 10.12
6.6.0
3.10.3
aurelia-cli 0.19.0
all
ESNext
Current behavior:
Other binding still evaluated when if binding is false, this cause error
Expected/desired behavior:
https://gist.run/?id=55559f3bd606aa854502f3ddbbcad480
Toggle the SVG line, when removing line from DOM, error appears in Chrome console
Error: <line> attribute x1: Expected length, "null".
I tried to move the if binding to parent. like this
But it does not help.
expect
x1.bind="line.sx"
not evaluated whenthis.line
is null.I was expecting if binding logic is executed before other bindings, once if binding removes the node from DOM, other binding won't happen.
Not sure whether this is related to Aurelia's SVG implementation. So far, I only saw this on SVG.
The text was updated successfully, but these errors were encountered: