polymer-1.0 Getting started with polymer-1.0

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Remarks

  • The example above shows bare minimum structure of a custom(Polymer) element using local dom.
  • A Polymer element can also be created entirely using script tag, but that is not part of this topic.
  • Even though style tag is not a part of bare minimum structure it has been kept there just for understanding purpose.
  • Also, script tag can be used in both imperative and declarative fashion i.e user can have a separate js file with atleast above written code and then refer it in element.
  • Please note that id of dom-module and is property of Polymer constructor should always be same.

Versions

VersionRelease Date
v1.6.02016-06-29
v1.5.02016-05-31
v1.4.02016-05-18
v1.0.02015-05-27

Element structure

Defining an element with no content.

<dom-module id="empty-element">
  <template>
    <style>
    </style>
  </template>

  <script>
    Polymer({
      is: 'empty-element',
    });
  </script>
</dom-module>
 

And then you can use the new element in any other pages.

<!DOCTYPE html>
<html>
    <head>
        <!-- Using lite version as Polymer does not require Polyfill for Shadow Dom -->
        <script src="path/to/bower_components/webcomponentsjs/webcomponents-lite.min.js"></script>
        <!-- Importing the element assuming file name is also empty-element.html -->
        <link rel="import" href="empty-element.html">
    </head>

    <body>
        <empty-element></empty-element>
    </body>
</html>
 


Got any polymer-1.0 Question?