Skip to content
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

amp-bind: Don't depend on template element's presence inside dynamic elements #8341

Closed
kmh287 opened this issue Mar 23, 2017 · 3 comments
Closed
Assignees

Comments

@kmh287
Copy link
Contributor

kmh287 commented Mar 23, 2017

For instance, amp-list allows developers to specify the id of a template rather than including it as a descendant of the amp-list element. Under the current strategy, if a developer puts a template as a child of the body tag, bind will observe the body tag for mutations to its children.

We should change bind to not depend on a template's position to determine which elements to observe for mutations. That means depending on the element using the template (form, amp-list etc.) rather than the template to determine what to observe. Some potential solutions for forms are:

1: Keep the same strategy we have now if a template is a descendant of a form tag. Since forms must have templates as descendants of their <div success> and <div error> elements (if they exist), the current strategy would work as-is.
2: Specifically look for the success and error divs and observe them for mutations to their children.

@choumx what are your thoughts on this?

@dreamofabear
Copy link

If templates can be declared anywhere, we shouldn't rely on their location (perhaps forms will support template-by-id at some point). So (2) is the right strategy, though as mentioned previously it's best if delegated to the dynamic component itself.

@kmh287
Copy link
Contributor Author

kmh287 commented Mar 23, 2017

Could we accomplish that with an override-able method on base element? For instance, a method that returns an array of elements that should be observed for changes in their descendants.

@dreamofabear
Copy link

And custom-element.js to forward it to the implementation object. You can see mutatedAttributesCallback as an example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants