GithubHelp home page GithubHelp logo

tori3 / webcomponentsjs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from webcomponents/webcomponentsjs

1.0 2.0 0.0 1.89 MB

A suite of polyfills supporting the HTML Web Components specs

Home Page: http://webcomponents.org/polyfills/

License: Other

Shell 0.06% JavaScript 86.59% HTML 12.58% CSS 0.76%

webcomponentsjs's Introduction

webcomponents.js

Join the chat at https://gitter.im/webcomponents/webcomponentsjs

A suite of polyfills supporting the Web Components specs:

Custom Elements: allows authors to define their own custom tags (spec).

HTML Imports: a way to include and reuse HTML documents via other HTML documents (spec).

Shadow DOM: provides encapsulation by hiding DOM subtrees under shadow roots (spec).

This also folds in polyfills for MutationObserver and WeakMap.

Releases

Pre-built (concatenated & minified) versions of the polyfills are maintained in the tagged versions of this repo. There are two variants:

webcomponents.js includes all of the polyfills.

webcomponents-lite.js includes all polyfills except for shadow DOM.

Browser Support

Our polyfills are intended to work in the latest versions of evergreen browsers. See below for our complete browser support matrix:

Polyfill IE10 IE11+ Chrome* Firefox* Safari 7+* Chrome Android* Mobile Safari*
Custom Elements ~
HTML Imports ~
Shadow DOM
Templates

*Indicates the current version of the browser

~Indicates support may be flaky. If using Custom Elements or HTML Imports with Shadow DOM, you will get the non-flaky Mutation Observer polyfill that Shadow DOM includes.

The polyfills may work in older browsers, however require additional polyfills (such as classList) to be used. We cannot guarantee support for browsers outside of our compatibility matrix.

Manually Building

If you wish to build the polyfills yourself, you'll need node and gulp on your system:

  • install node.js using the instructions on their website
  • use npm to install gulp.js: npm install -g gulp

Now you are ready to build the polyfills with:

# install dependencies
npm install
# build
gulp build

The builds will be placed into the dist/ directory.

Contribute

See the contributing guide

License

Everything in this repository is BSD style license unless otherwise specified.

Copyright (c) 2015 The Polymer Authors. All rights reserved.

Helper utilities

WebComponentsReady

Under native HTML Imports, <script> tags in the main document block the loading of such imports. This is to ensure the imports have loaded and any registered elements in them have been upgraded.

The webcomponents.js and webcomponents-lite.js polyfills parse element definitions and handle their upgrade asynchronously. If prematurely fetching the element from the DOM before it has an opportunity to upgrade, you'll be working with an HTMLUnknownElement.

For these situations (or when you need an approximate replacement for the Polymer 0.5 polymer-ready behavior), you can use the WebComponentsReady event as a signal before interacting with the element. The criteria for this event to fire is all Custom Elements with definitions registered by the time HTML Imports available at load time have loaded have upgraded.

window.addEventListener('WebComponentsReady', function(e) {
  // imports are loaded and elements have been registered
  console.log('Components are ready');
});

Known Issues

Custom element's constructor property is unreliable

See #215 for background.

In Safari and IE, instances of Custom Elements have a constructor property of HTMLUnknownElementConstructor and HTMLUnknownElement, respectively. It's unsafe to rely on this property for checking element types.

It's worth noting that customElement.__proto__.__proto__.constructor is HTMLElementPrototype and that the prototype chain isn't modified by the polyfills(onto ElementPrototype, etc.)

Contenteditable elements do not trigger MutationObserver

Using the MutationObserver polyfill, it isn't possible to monitor mutations of an element marked contenteditable. See the mailing list

ShadowCSS: :host-context(...):host(...) doesn't work

See #16 for background.

Under the shadow DOM polyfill, rules like:

:host-context(.foo):host(.bar) {...}

don't work, despite working under native Shadow DOM. The solution is to use polyfill-next-selector like:

polyfill-next-selector { content: '.foo :host.bar, :host.foo.bar'; }

execCommand and contenteditable isn't supported under Shadow DOM

See #212

execCommand, and contenteditable aren't supported under the ShadowDOM polyfill, with commands that insert or remove nodes being especially prone to failure.

webcomponentsjs's People

Contributors

0x24a537r9 avatar addyosmani avatar agrieve avatar arv avatar bouk avatar dfreedm avatar edrachev avatar eeid26 avatar eisenbergeffect avatar garlicnation avatar gitter-badger avatar jacobrossi avatar jakemac53 avatar jdalton avatar jerryorr avatar jmalonzo avatar keanulee avatar kevinpschaaf avatar mysticatea avatar nazar-pc avatar nevir avatar noyainrain avatar shama avatar sorvell avatar talee avatar threeday0905 avatar timoxley avatar tjsavage avatar vicb avatar webreflection avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.