Socket
Socket
Sign inDemoInstall

@polymer/polymer

Package Overview
Dependencies
818
Maintainers
2
Versions
49
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @polymer/polymer

The Polymer library makes it easy to create your own web components. Give your element some markup and properties, and then use it on a site. Polymer provides features like dynamic templates and data binding to reduce the amount of boilerplate you need to


Version published
Maintainers
2
Install size
10.7 MB
Created

Changelog

Source

v3.0.0 (2018-05-08)

  • use released versions of shadycss and webcomponentsjs (commit)

  • Bump dependencies (commit)

  • Run Chrome & FF serially to try and help flakiness (commit)

  • Fix lint warning (commit)

  • Bump to cli 1.7.0 (commit)

  • Removing support for returning strings from template getter. (Per previous documented deprecation: https://www.polymer-project.org/2.0/docs/devguide/dom-template#templateobject) (commit)

  • Fix typos and nits (commit)

  • Update to Gulp 4 (commit)

  • Add serve command to package.json and update package-lock.json (commit)

  • Fix for browsers that don't have input.labels. (commit)

  • Tweak introductory note, fix webpack capitalization (commit)

  • gestures: Avoid spreading non-iterable in older browsers (commit)

  • wip (commit)

  • Readme: very small tweaks (commit)

  • Tweak wording. (commit)

  • Fix link (commit)

  • Re-order sections (commit)

  • Fix LitElement typo (commit)

  • Depend on polymer-cli rather than wct (commit)

  • Minor tweaks (commit)

  • Update README for 3.x (commit)

  • Update Edge testing versions. (commit)

  • Exclude all Edge versions from keyframe/font tests. (commit)

  • Update wcjs version. (commit)

  • Add .npmignore file (#5215) (commit)

  • Use node 9 (commit)

  • Use module flags for wct (commit)

  • Use babel parser for aslant for dynamic import. (commit)

  • Fix lint errors. (commit)

  • 3.0.0-pre.13 (commit)

  • [package.json] Remove version script (commit)

  • Update dependencies (commit)

  • Fix test typo on Chrome (commit)

  • Fixes IE11 test issues (commit)

  • Fixes styling tests related to using HTML Imports (commit)

  • Remove crufty global (fixes globals.html test) (commit)

  • Update to webcomponents 2.0.0 and webcomponents-bundle.js (commit)

  • Fix meaningful whitespace in test assertion (commit)

  • Fix latent mistake using old SD API (commit)

  • Add global for wct callback when amd compiling (commit)

  • Eliminate pre-module code from resolveUrl tests (commit)

  • Improve documentation and legibility. (commit)

  • Add some global whitelists (commit)

  • Fix references to js files instead of html files (commit)

  • Fix glob patterns for eslint (commit)

  • Fix ESLint warnings (commit)

  • Eliminate more canonical path usage (commit)

  • Eliminate canonical path to wcjs (commit)

  • Remove extra polymer-legacy.js imports (commit)

  • Clean up Polymer fn import (commit)

  • Add WCT config used by all tests (commit)

  • Clean up exports (commit)

  • Allow Polymer fn's call to Class to be overridden. (commit)

  • add sill-relevant, deleted tests back in (commit)

  • manually change inter-package dep imports from paths to names (commit)

  • manually add assetpath (import.meta.url) for tests that require it (commit)

  • move behavior definition to before usage (commit)

  • define omitted class declaration (commit)

  • remove < and replace with < for innerHTML (commit)

  • fixed typo causing test to fail (commit)

  • fix missing dom-module in modulization (commit)

  • revert module wait (commit)

  • wait for elements in other modules to be defined (commit)

  • no more undefined.hasShadow (commit)

  • removed link rel import type css tests (commit)

  • delete debugger (commit)

  • skip link rel import type css tests on native imports (commit)

  • add missing css html import (commit)

  • remove importHref tests (commit)

  • Import Polymer function in tests from legacy/polymer-fn.js (commit)

  • Export Polymer function from polymer-legacy.js (commit)

  • Add new wct deps. (commit)

  • Fixup a few places where comments were misplaced. (commit)

  • Fixup license comments. (commit)

  • Update package.json from modulizer's output, set polymer-element.js as main. (commit)

  • Replace sources with modulizer output. (commit)

  • Rename HTML files to .js files to trick git's rename detection. (commit)

  • Delete typings for now. (commit)

  • Add reasoning for suppress missingProperties (commit)

  • Don't rely on dom-module synchronously until WCR. (commit)

  • Avoid closure warnings. (commit)

  • Add ability to define importMeta on legacy elements. Fixes #5163 (commit)

  • Allow legacy element property definitions with only a type. Fixes #5173 (commit)

  • Update docs. (commit)

  • Use Polymer.ResolveUrl.pathFromUrl (commit)

  • Fix test under shadydom. Slight logic refactor. (commit)

  • Fix lint warning (commit)

  • Add importMeta getter to derive importPath from modules. Fixes #5163 (commit)

  • Reference dependencies as siblings in tests. (commit)

  • Update types (commit)

  • Add note about performance vs correctness (commit)

  • Update types. (commit)

  • Lint clean. (commit)

  • Pass through fourth namespace param on attributeChangedCallback. (commit)

  • Add a @const annotation to help the Closure Compiler understand that Polymer.Debouncer is the name of a type. (commit)

  • [ci skip] update changelog (commit)

  • Update docs and types (commit)

  • Update perf test to use strict-binding-parser (commit)

  • Correct import paths (commit)

  • Only store method once for dynamic functions (commit)

  • Move strict-binding-parser to lib/mixins (commit)

  • Rename to StrictBindingParser (commit)

  • Fix linter errors (commit)

  • Extract to a mixin (commit)

  • Add missing dependency to bower.json (commit)

  • Fix linter warning (commit)

  • Add documentation (commit)

  • Add performance test for binding-expressions (commit)

  • Rewrite parser to use switch-case instead of functions (commit)

  • Remove escaping from bindings (commit)

  • Fix linter warning (commit)

  • Refactor to be functional and add more tests (commit)

  • Fix linter warnings (commit)

  • Rewrite expression parser to state machine (commit)

Readme

Source

Polymer

Build Status

ℹ️ Note: This is the current stable version of the Polymer library. At Google I/O 2018 we announced a new Web Component base class, LitElement, as a successor to the PolymerElement base class in this library.

If you're starting a new project, we recommend that you consider using LitElement instead.

If you have a project you've built with an earlier version of the Polymer library, we recommend that you migrate to 3.0 for best compatibility with the JavaScript ecosystem. Thanks to the interoperability of Web Components, elements built with Polymer 3.0 and LitElement can be mixed and matched in the same app, so once you have updated your project to Polymer 3.0, you can migrate to LitElement incrementally, one element at a time. See our blog post on the Polymer Project roadmap for more information.

Polymer lets you build encapsulated, reusable Web Components that work just like standard HTML elements, to use in building web applications. Using a Web Commponent built with Polymer is as simple as importing its definition then using it like any other HTML element:

<!-- Import a component -->
<script src="https://unpkg.com/@polymer/paper-checkbox@next/paper-checkbox.js?module" type="module" ></script>

<!-- Use it like any other HTML element -->
<paper-checkbox>Web Components!</paper-checkbox>

Web Components are now implemented natively on Safari and Chrome (~70% of installed browsers), and run well on Firefox, Edge, and IE11 using polyfills. Read more below.

Getting started

  • The easiest way to try out Polymer is to use one of these online tools:

  • You can also save this HTML file to a local file and run it in any browser that supports JavaScript Modules.

  • When you're ready to use Polymer in a project, install it via npm. To run the project in the browser, a module-compatible toolchain is required. We recommend installing the Polymer CLI to and using its development server as follows.

    1. Add Polymer to your project:

      npm i @polymer/polymer

    2. Create an element by extending PolymerElement and calling customElements.define with your class (see the examples below).

    3. Install the Polymer CLI:

      npm i -g polymer-cli@next

    4. Run the development server and open a browser pointing to its URL:

      polymer serve

    Polymer 3.0 is published on npm using JavaScript Modules. This means it can take advantage of the standard native JavaScript module loader available in all current major browsers.

    However, since Polymer uses npm conventions to reference dependencies by name, a light transform to rewrite specifiers to URLs is required to run in the browser. The polymer-cli's development server polymer serve, as well as polymer build (for building an optimized app for deployment) automatically handles this transform.

    Tools like webpack and Rollup can also be used to serve and/or bundle Polymer elements.

Minimal Example

  1. Create a class that extends PolymerElement.
  2. Implement a static properties getter that describes the element's public property/attribute API (these automatically become observed attributes).
  3. Then implement a template getter that returns an HTMLTemplateElement describing the element's rendering, including encapsulated styling and any property bindings.
  <script src="node_modules/@webcomponents/webcomponents-loader.js"></script>
  <script type="module">
    import {PolymerElement, html} from '@polymer/polymer';

    class MyElement extends PolymerElement {
      static get properties() { return { mood: String }}
      static get template() {
        return html`
          <style> .mood { color: green; } </style>
          Web Components are <span class="mood">[[mood]]</span>!
        `;
      }
    }

    customElements.define('my-element', MyElement);
  </script>

  <my-element mood="happy"></my-element>

Overview

Web components are an incredibly powerful new set of primitives baked into the web platform, and open up a whole new world of possibility when it comes to componentizing front-end code and easily creating powerful, immersive, app-like experiences on the web.

Polymer is a lightweight library built on top of the web standards-based Web Components APIs, and makes it easier to build your very own custom HTML elements. Creating reusable custom elements - and using elements built by others - can make building complex web applications easier and more efficient.

By being based on the Web Components APIs built in the browser (or polyfilled where needed), elements built with Polymer are:

  • Built from the platform up
  • Self-contained
  • Re-usable
  • Interoperable across frameworks

Among many ways to leverage custom elements, they can be particularly useful for building reusable UI components. Instead of continually re-building a specific navigation bar or button in different frameworks and for different projects, you can define this element once using Polymer, and then reuse it throughout your project or in any future project.

Polymer provides a declarative syntax to easily create your own custom elements, using all standard web technologies - define the structure of the element with HTML, style it with CSS, and add interactions to the element with JavaScript.

Polymer also provides optional two-way data-binding, meaning:

  1. When properties in the model for an element get updated, the element can update itself in response.
  2. When the element is updated internally, the changes can be propagated back to the model.

Polymer is designed to be flexible, lightweight, and close to the web platform - the library doesn't invent complex new abstractions and magic, but uses the best features of the web platform in straightforward ways to simply sugar the creation of custom elements.

About Polymer 3.0

Polymer 3.0 is now released to stable, and introduces a major change to how Polymer is distributed: from HTML Imports on Bower, to JS modules on npm. Otherwise, the API is almost entirely backward compatible with Polymer 2.0 (the only changes are removing APIs related to HTML Imports like importHref, and converting Polymer's API to be module-based rather than globals-based).

Migrating to Polymer 3.0 by hand is mostly mechanical:

  • Components should be defined in JS modules instead of in HTML
  • Templates should be encoded in JS modules using a static get template() getter on PolymerElement subclasses using the html tagged template literal function (which parses HTMLTemplateElements out of strings in JS) rather than using <template> elements in a <dom-module>
  • All dependencies should be imported JS module imports rather than HTML Imports.

However, the polymer-modulizer tool automates the vast majority of this migration work. Please see details on that repo for automated conversion of Polymer 2.0 apps and elements to Polymer 3.0.

👀 Looking for Polymer v2.x? Please see the the v2 branch.

👀 Looking for Polymer v1.x? Please see the the v1 branch.

Contributing

The Polymer team loves contributions from the community! Take a look at our contributing guide for more information on how to contribute. Please file issues on the Polymer issue tracker following the issue template and contributing guide issues.

Communicating with the Polymer team

Beyond GitHub, we try to have a variety of different lines of communication available:

License

The Polymer library uses a BSD-like license that is available here

FAQs

Last updated on 09 May 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc