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

Prevent invalid binding in re-written templates #814

Merged
merged 1 commit into from Mar 19, 2013

Conversation

Projects
None yet
2 participants
@mbest
Copy link
Member

mbest commented Jan 25, 2013

With string templates, if the HTML is invalid in some way, the browser will attempt to fix it, often by removing invalid elements. If that invalid element has a binding, Knockout still tries to do that binding on whichever element is after it.

We fixed a particular consequence of this in #660, but should probably fix the problem more generally. Likely this will mean that we track the tagName of the binding's element and ensure that the binding is applied to an element with the same name.

Prevent binding to missing nodes in case of malformed template (#814)
Reverts change from 8bb9b39 that worked around a specific instance of this problem.

@mbest mbest referenced this pull request Mar 16, 2013

Closed

March 2013 iteration #877

@SteveSanderson

This comment has been minimized.

Copy link
Contributor

SteveSanderson commented on src/utils.js in 1dfd516 Mar 19, 2013

The reason for removing text node support - is it just that KO now only ever passes elements (not text nodes) to setTextContent?

That is, the only case where previously we might pass a text node was when a template markup was malformed and a text binding was being applied incorrectly to a text node instead of the intended element?

This comment has been minimized.

Copy link
Contributor

SteveSanderson replied Mar 19, 2013

Actually, ignore this question. After re-reading the notes for #660, it's pretty clear why you did this (i.e., it's exactly as I described above). And the existing spec Should not throw errors if trying to apply text to a non-rendered node covers the new behavior.

SteveSanderson added a commit that referenced this pull request Mar 19, 2013

Merge pull request #814 from SteveSanderson/814-prevent-invalid-binding
Prevent invalid binding in re-written templates

@SteveSanderson SteveSanderson merged commit a703974 into master Mar 19, 2013

@SteveSanderson

This comment has been minimized.

Copy link
Contributor

SteveSanderson commented Mar 19, 2013

Looks good - thanks!

@mbest mbest deleted the 814-prevent-invalid-binding branch Mar 19, 2013

mikekidder added a commit to mikekidder/knockout that referenced this pull request Apr 17, 2013

Prevent binding to missing nodes in case of malformed template (knock…
…out#814)

Reverts change from 8bb9b39 that worked around a specific instance of this problem.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment