-
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
Can't instantiate component under CE polyfill (where hostAttributes triggers property change handler) #1673
Comments
We'll take a look at fixing this. However, it's an odd construction to set an attribute on yourself to initialize your own property, and we'd probably consider this an anti-pattern; is there a reason you don't just use value: 'foo' for the target property? We generally try to avoid using attributes for anything dynamic, and only for initial configuration in markup, since dynamic attribute manipulation is detrimental to performance |
@kevinpschaaf The sample code here is intentionally short to make the bug easier to see; the actual use case is slightly more complex. We have a Polymer behavior that defines an attribute like So, while the result is that a component is ultimately setting an attribute on itself, it feels pretty different, because the attribute was defined separately in the behavior. We think this is a use case worth supporting. |
Ok, but is there a reason it is important to think about |
First: that's an interesting jsBin. I hadn't known that a property could be defined in both a behavior and the component. That's cool! But also, as far as I can tell, undocumented. Second: Your jsBin example somewhat flips around what I'd described. We have a behavior that defines an attribute (including a changed handler), and the component wants to set that. Your solution has the component define the attribute, and the behavior provides a default value, which is somewhat the opposite. That said, your solution works for the particular use case that motivated us filing this issue. While I think we're unblocked for the moment, we'd still like to see this fixed. To answer your question, yes, there are reasons for using attributes instead of properties: the former can be referenced in styles. As a case in point, we have another behavior called Generic that defines a |
Thanks for bearing with me-- glad you're unblocked. Understanding the use case and available workarounds helps set priority. We took a quick look today and it is related to differences in polyfill timing of |
Filed webcomponents/webcomponentsjs#325 on webcomponents.js. The issue can probably be worked around by reordering |
Thanks for the update. |
Fixes #1673: ensure instance effects exist before marshaling attributes.
Polymer 1.0 appears to contain a regression from Polymer 0.9. This gist shows a component that uses hostAttributes to set a property; setting the property triggers a property changed handler.
This element cannot be instantiated under Shady DOM. It raises an exception:
It looks like a low-level function called _propertySet is trying to access a property bag called data which has not yet been created.
Code such as this used to work up to Polymer 0.9.
This is probably a small bug somewhere, but it's currently preventing Basic Web Components like basic-list-box and basic-carousel from working under Polymer 1.0. We'd obviously like to be able to have those components work with the final 1.0 release.
The text was updated successfully, but these errors were encountered: