README.md
1 webcomponents.js
2 ================
3
4 [![Join the chat at https://gitter.im/webcomponents/webcomponentsjs](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/webcomponents/webcomponentsjs?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
5
6 A suite of polyfills supporting the [Web Components](http://webcomponents.org) specs:
7
8 **Custom Elements**: allows authors to define their own custom tags ([spec](https://w3c.github.io/webcomponents/spec/custom/)).
9
10 **HTML Imports**: a way to include and reuse HTML documents via other HTML documents ([spec](https://w3c.github.io/webcomponents/spec/imports/)).
11
12 **Shadow DOM**: provides encapsulation by hiding DOM subtrees under shadow roots ([spec](https://w3c.github.io/webcomponents/spec/shadow/)).
13
14 This also folds in polyfills for `MutationObserver` and `WeakMap`.
15
16
17 ## Releases
18
19 Pre-built (concatenated & minified) versions of the polyfills are maintained in the [tagged versions](https://github.com/webcomponents/webcomponentsjs/releases) of this repo. There are two variants:
20
21 `webcomponents.js` includes all of the polyfills.
22
23 `webcomponents-lite.js` includes all polyfills except for shadow DOM.
24
25
26 ## Browser Support
27
28 Our polyfills are intended to work in the latest versions of evergreen browsers. See below
29 for our complete browser support matrix:
30
31 | Polyfill | IE10 | IE11+ | Chrome* | Firefox* | Safari 7+* | Chrome Android* | Mobile Safari* |
32 | ---------- |:----:|:-----:|:-------:|:--------:|:----------:|:---------------:|:--------------:|
33 | Custom Elements | ~ | | | | | | |
34 | HTML Imports | ~ | | | | | | |
35 | Shadow DOM | | | | | | | |
36 | Templates | | | | | | | |
37
38
39 *Indicates the current version of the browser
40
41 ~Indicates support may be flaky. If using Custom Elements or HTML Imports with Shadow DOM,
42 you will get the non-flaky Mutation Observer polyfill that Shadow DOM includes.
43
44 The polyfills may work in older browsers, however require additional polyfills (such as classList)
45 to be used. We cannot guarantee support for browsers outside of our compatibility matrix.
46
47
48 ### Manually Building
49
50 If you wish to build the polyfills yourself, you'll need `node` and `gulp` on your system:
51
52 * install [node.js](http://nodejs.org/) using the instructions on their website
53 * use `npm` to install [gulp.js](http://gulpjs.com/): `npm install -g gulp`
54
55 Now you are ready to build the polyfills with:
56
57 # install dependencies
58 npm install
59 # build
60 gulp build
61
62 The builds will be placed into the `dist/` directory.
63
64 ## Contribute
65
66 See the [contributing guide](CONTRIBUTING.md)
67
68 ## License
69
70 Everything in this repository is BSD style license unless otherwise specified.
71
72 Copyright (c) 2015 The Polymer Authors. All rights reserved.
73
74 ## Known Issues
75
76 * [Custom element's constructor property is unreliable](#constructor)
77 * [Contenteditable elements do not trigger MutationObserver](#contentedit)
78 * [ShadowCSS: :host-context(...):host(...) doesn't work](#hostcontext)
79 * [execCommand isn't supported under Shadow DOM](#execcommand)
80
81 ### Custom element's constructor property is unreliable <a id="constructor"></a>
82 See [#215](https://github.com/webcomponents/webcomponentsjs/issues/215) for background.
83
84 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.
85
86 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.)
87
88 ### Contenteditable elements do not trigger MutationObserver <a id="contentedit"></a>
89 Using the MutationObserver polyfill, it isn't possible to monitor mutations of an element marked `contenteditable`.
90 See [the mailing list](https://groups.google.com/forum/#!msg/polymer-dev/LHdtRVXXVsA/v1sGoiTYWUkJ)
91
92 ### ShadowCSS: :host-context(...):host(...) doesn't work <a id="hostcontext"></a>
93 See [#16](https://github.com/webcomponents/webcomponentsjs/issues/16) for background.
94
95 Under the shadow DOM polyfill, rules like:
96 ```
97 :host-context(.foo):host(.bar) {...}
98 ```
99 don't work, despite working under native Shadow DOM. The solution is to use `polyfill-next-selector` like:
100
101 ```
102 polyfill-next-selector { content: '.foo :host.bar, :host.foo.bar'; }
103 ```
104
105 ### execCommand and contenteditable isn't supported under Shadow DOM <a id="execcommand"></a>
106 See [#212](https://github.com/webcomponents/webcomponentsjs/issues/212)
107
108 `execCommand`, and `contenteditable` aren't supported under the ShadowDOM polyfill, with commands that insert or remove nodes being especially prone to failure.
109