-
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
problem accessing polymer properties from content script #753
Comments
Wondering if the issues you're seeing are related to this bug: https://code.google.com/p/chromium/issues/detail?id=390807 |
@esprehn any idea why setting properties on an element using a content script might not work? |
Any news on this? I guess nothing will happen in the near-term anyway, so we'll continue manipulating the attributes in the dom. |
@rafaelw could this have something to do with |
This can't work, content scripts see a totally different wrapper around the element. Specifically they see HTMLElement while the page sees the real MyCustomElement class. There's no way to make this work currently without some kind of serialization system in the middle. ex. the Array type in the content script is different, so doing element.property = [1,2,3] needs to clone the array into the main world otherwise you leak the isolated world into the page and also end up with an array that fails instanceof Array. This doesn't work with complex APIs though, if the property expects some model object there's no way to create and clone across the worlds since JS has no concept of a clone() callback on objects. It's all symptoms of the same thing going on in http://crbug.com/390807 My suggestion would be to appendChild a script into the main page like |
The proxy script sounds like an interesting solution. |
Closing this here, thanks everyone! |
It seems I can set an attribute of a polymer element ok from inside a content script, but setting an element's property doesn't work and/or doesn't trigger the corresponding Changed function.
I also had trouble getting events in the content script.
I wrote an example here :
https://github.com/davidmaxwaterman/cs_polymer_test
and would appreciate knowing if I'm doing anything wrong and/or how to do what I'm trying to do.
The text was updated successfully, but these errors were encountered: