-
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
How to extend PolymerElements? #4686
Comments
You can. There are some docs here: https://www.polymer-project.org/2.0/docs/devguide/custom-elements#extending-other-elements I can't reproduce your error with the code you showed above, but if I add a new So it looks like you're replacing the template of the parent element. If you want to insert content into the parent element template, see the second link above. You can also use composition (create a parent element that includes an One catch with extending an element and manipulating its template is that you need to know which internal elements the parent element references (for example, in this case, the app-drawer code is trying to access |
Extending other elements and modifying templates is a topic that probably needs a bit more exploration and documentation for good patterns. |
Two safe patterns you can use when subclassing and modifying a template are:
Creating a new template for the subclass from whole cloth is more risky because as @arthurevans pointed out Polymer elements may reference specific nodes from the template in imperative code (typically nodes with |
Here is an example of how to extend element and also cloning the template and being able to use own <style> on the sub-element. Also a link to @kevinpschaaf kevinpschaaf example from another thread is here Below is gist of how template can be cloned plus attached the <style>
|
Closing since there are now a number of examples about how to do this. Please re-open if it needs further clarification. |
I'm trying to extend
app-drawer
following the instructions here #4556Having this code I'm getting the following error in chrome. Other browsers not tested.
error:
Is it possible to extend PolymerElements at all? No documentation found
The text was updated successfully, but these errors were encountered: