Skip to content
This repository has been archived by the owner on Sep 20, 2019. It is now read-only.

Commit

Permalink
release v0.7.21
Browse files Browse the repository at this point in the history
  • Loading branch information
dfreedm committed Feb 19, 2016
2 parents ce9c859 + b76bfaa commit 19ffcd9
Show file tree
Hide file tree
Showing 16 changed files with 573 additions and 63 deletions.
2 changes: 1 addition & 1 deletion CustomElements.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
*/
// @version 0.7.20
// @version 0.7.21
if (typeof WeakMap === "undefined") {
(function() {
var defineProperty = Object.defineProperty;
Expand Down
2 changes: 1 addition & 1 deletion CustomElements.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions HTMLImports.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
*/
// @version 0.7.20
// @version 0.7.21
if (typeof WeakMap === "undefined") {
(function() {
var defineProperty = Object.defineProperty;
Expand Down Expand Up @@ -948,7 +948,7 @@ window.HTMLImports.addModule(function(scope) {
if (doc && this._mayParse.indexOf(doc) < 0) {
this._mayParse.push(doc);
var nodes = doc.querySelectorAll(this.parseSelectorsForNode(doc));
for (var i = 0, l = nodes.length, p = 0, n; i < l && (n = nodes[i]); i++) {
for (var i = 0, l = nodes.length, n; i < l && (n = nodes[i]); i++) {
if (!this.isParsed(n)) {
if (this.hasResource(n)) {
return nodeIsImport(n) ? this.nextToParseInDoc(n.__doc, n) : n;
Expand Down
2 changes: 1 addition & 1 deletion HTMLImports.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion MutationObserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
*/
// @version 0.7.20
// @version 0.7.21
if (typeof WeakMap === "undefined") {
(function() {
var defineProperty = Object.defineProperty;
Expand Down
2 changes: 1 addition & 1 deletion MutationObserver.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,35 @@ window.addEventListener('WebComponentsReady', function(e) {

## Known Issues

* [Limited CSS encapsulation](#encapsulation)
* [Element wrapping / unwrapping limitations](#wrapping)
* [Custom element's constructor property is unreliable](#constructor)
* [Contenteditable elements do not trigger MutationObserver](#contentedit)
* [ShadowCSS: :host-context(...):host(...) doesn't work](#hostcontext)
* [ShadowCSS: :host(.zot:not(.bar:nth-child(2))) doesn't work](#nestedparens)
* [HTML imports: document.currentScript doesn't work as expected](#currentscript)
* [execCommand isn't supported under Shadow DOM](#execcommand)

### Limited CSS encapsulation <a id="encapsulation"></a>
Under native Shadow DOM, CSS selectors cannot cross the shadow boundary. This means document level styles don't apply to shadow roots, and styles defined within a shadow root don't apply outside of that shadow root. [Several selectors](http://www.html5rocks.com/en/tutorials/webcomponents/shadowdom-201/) are provided to be able to deal with the shadow boundary.

The Shadow DOM polyfill can't prevent document styles from leaking into shadow roots. It can, however, encapsulate styles within shadow roots to some extent. This behavior isn't automatically emulated by the Shadow DOM polyfill, but it can be achieved by manually using the included ShadowCSS shim:

```
WebComponents.ShadowCSS.shimStyling( shadowRoot, scope );
```

... where `shadowRoot` is the shadow root of a DOM element, and `scope` is the name of the scope used to prefix the selectors. This removes all `<style>` elements from the shadow root, rewrites it rules using the given scope and reinserts the style as a document level stylesheet. Note that the `:host` and `:host-context` pseudo classes are also rewritten.

For a full explanation on the implementation and both the possibilities and the limitations of ShadowCSS please view the documentation in the [ShadowCSS source](src/ShadowCSS/ShadowCSS.js).

### Element wrapping / unwrapping limitations <a id="wrapping"></a>
The Shadow DOM polyfill is implemented by [wrapping](http://webcomponents.org/polyfills/shadow-dom/#wrappers) DOM elements whenever possible. It does this by wrapping methods like `document.querySelector` to return wrapped DOM elements. This has a few caveats:
* Not _everything_ can be wrapped. For example, elements like `document`, `window`, `document.body`, `document.fullscreenElement` and others are non-configurable and thus cannot be overridden.
* Wrappers don't support [live NodeLists](https://developer.mozilla.org/en-US/docs/Web/API/NodeList#A_sometimes-live_collection) like `HTMLElement.childNodes` and `HTMLFormElement.elements`. All NodeLists are snapshotted upon read. See [#217](https://github.com/webcomponents/webcomponentsjs/issues/217) for an explanation.

In order to work around these limitations the polyfill provides the `ShadowDOMPolyfill.wrap` and `ShadowDOMPolyfill.unwrap` methods to respectively wrap and unwrap DOM elements manually.

### Custom element's constructor property is unreliable <a id="constructor"></a>
See [#215](https://github.com/webcomponents/webcomponentsjs/issues/215) for background.

Expand All @@ -119,6 +143,12 @@ don't work, despite working under native Shadow DOM. The solution is to use `pol
polyfill-next-selector { content: '.foo :host.bar, :host.foo.bar'; }
```

### ShadowCSS: :host(.zot:not(.bar:nth-child(2))) doesn't work <a id="nestedparens"></a>
ShadowCSS `:host()` rules can only have (at most) 1-level of nested parentheses in its argument selector under ShadowCSS. For example, `:host(.zot)` and `:host(.zot:not(.bar))` both work, but `:host(.zot:not(.bar:nth-child(2)))` does not.

### HTML imports: document.currentScript doesn't work as expected <a id="currentscript"></a>
In native HTML Imports, document.currentScript.ownerDocument references the import document itself. In the polyfill use document._currentScript.ownerDocument (note the underscore).

### execCommand and contenteditable isn't supported under Shadow DOM <a id="execcommand"></a>
See [#212](https://github.com/webcomponents/webcomponentsjs/issues/212)

Expand Down
7 changes: 2 additions & 5 deletions ShadowDOM.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
*/
// @version 0.7.20
// @version 0.7.21
if (typeof WeakMap === "undefined") {
(function() {
var defineProperty = Object.defineProperty;
Expand Down Expand Up @@ -3411,10 +3411,7 @@ window.ShadowDOMPolyfill = {};
var unwrappedActiveElement = unwrap(this).ownerDocument.activeElement;
if (!unwrappedActiveElement || !unwrappedActiveElement.nodeType) return null;
var activeElement = wrap(unwrappedActiveElement);
if (activeElement === this.host) {
return null;
}
while (!this.contains(activeElement) && !this.host.contains(activeElement)) {
while (!this.contains(activeElement)) {
while (activeElement.parentNode) {
activeElement = activeElement.parentNode;
}
Expand Down
4 changes: 2 additions & 2 deletions ShadowDOM.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "webcomponentsjs",
"main": "webcomponents.js",
"version": "0.7.20",
"version": "0.7.21",
"homepage": "http://webcomponents.org",
"authors": [
"The Polymer Authors"
Expand Down
Loading

0 comments on commit 19ffcd9

Please sign in to comment.