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

Commit c4126d5

Browse files
committed
release 0.5.5-rc1
2 parents d31b29c + 6c9c717 commit c4126d5

13 files changed

+156
-66
lines changed

CustomElements.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,6 @@ if (typeof WeakMap === "undefined") {
315315
this.addTransientObserver(e.target);
316316

317317
case "DOMNodeInserted":
318-
var target = e.relatedNode;
319318
var changedNode = e.target;
320319
var addedNodes, removedNodes;
321320
if (e.type === "DOMNodeInserted") {
@@ -327,12 +326,12 @@ if (typeof WeakMap === "undefined") {
327326
}
328327
var previousSibling = changedNode.previousSibling;
329328
var nextSibling = changedNode.nextSibling;
330-
var record = getRecord("childList", target);
329+
var record = getRecord("childList", e.target.parentNode);
331330
record.addedNodes = addedNodes;
332331
record.removedNodes = removedNodes;
333332
record.previousSibling = previousSibling;
334333
record.nextSibling = nextSibling;
335-
forEachAncestorAndObserverEnqueueRecord(target, function(options) {
334+
forEachAncestorAndObserverEnqueueRecord(e.relatedNode, function(options) {
336335
if (!options.childList) return;
337336
return record;
338337
});
@@ -604,11 +603,13 @@ CustomElements.addModule(function(scope) {
604603
forDocumentTree(doc, upgradeDocument);
605604
}
606605
var originalCreateShadowRoot = Element.prototype.createShadowRoot;
607-
Element.prototype.createShadowRoot = function() {
608-
var root = originalCreateShadowRoot.call(this);
609-
CustomElements.watchShadow(this);
610-
return root;
611-
};
606+
if (originalCreateShadowRoot) {
607+
Element.prototype.createShadowRoot = function() {
608+
var root = originalCreateShadowRoot.call(this);
609+
CustomElements.watchShadow(this);
610+
return root;
611+
};
612+
}
612613
scope.watchShadow = watchShadow;
613614
scope.upgradeDocumentTree = upgradeDocumentTree;
614615
scope.upgradeSubtree = addedSubtree;

CustomElements.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

HTMLImports.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,6 @@ if (typeof WeakMap === "undefined") {
315315
this.addTransientObserver(e.target);
316316

317317
case "DOMNodeInserted":
318-
var target = e.relatedNode;
319318
var changedNode = e.target;
320319
var addedNodes, removedNodes;
321320
if (e.type === "DOMNodeInserted") {
@@ -327,12 +326,12 @@ if (typeof WeakMap === "undefined") {
327326
}
328327
var previousSibling = changedNode.previousSibling;
329328
var nextSibling = changedNode.nextSibling;
330-
var record = getRecord("childList", target);
329+
var record = getRecord("childList", e.target.parentNode);
331330
record.addedNodes = addedNodes;
332331
record.removedNodes = removedNodes;
333332
record.previousSibling = previousSibling;
334333
record.nextSibling = nextSibling;
335-
forEachAncestorAndObserverEnqueueRecord(target, function(options) {
334+
forEachAncestorAndObserverEnqueueRecord(e.relatedNode, function(options) {
336335
if (!options.childList) return;
337336
return record;
338337
});
@@ -967,12 +966,15 @@ HTMLImports.addModule(function(scope) {
967966
function isLinkRel(elt, rel) {
968967
return elt.localName === "link" && elt.getAttribute("rel") === rel;
969968
}
969+
function hasBaseURIAccessor(doc) {
970+
return !!Object.getOwnPropertyDescriptor(doc, "baseURI");
971+
}
970972
function makeDocument(resource, url) {
971973
var doc = document.implementation.createHTMLDocument(IMPORT_LINK_TYPE);
972974
doc._URL = url;
973975
var base = doc.createElement("base");
974976
base.setAttribute("href", url);
975-
if (!doc.baseURI) {
977+
if (!doc.baseURI && !hasBaseURIAccessor(doc)) {
976978
Object.defineProperty(doc, "baseURI", {
977979
value: url
978980
});

HTMLImports.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
webcomponents.js
22
================
33

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+
46
A suite of polyfills supporting the [Web Components](http://webcomponents.org) specs:
57

68
**Custom Elements**: allows authors to define their own custom tags ([spec](https://w3c.github.io/webcomponents/spec/custom/)).
@@ -21,6 +23,28 @@ Pre-built (concatenated & minified) versions of the polyfills are maintained in
2123
`webcomponents-lite.js` includes all polyfills except for shadow DOM.
2224

2325

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+
2448
### Manually Building
2549

2650
If you wish to build the polyfills yourself, you'll need `node` and `gulp` on your system:
@@ -41,4 +65,9 @@ The builds will be placed into the `dist/` directory.
4165

4266
See the [contributing guide](CONTRIBUTING.md)
4367

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.
4473

ShadowDOM.js

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,13 @@ window.ShadowDOMPolyfill = {};
115115
getOwnPropertyNames(window);
116116
function getWrapperConstructor(node) {
117117
var nativePrototype = node.__proto__ || Object.getPrototypeOf(node);
118+
if (isFirefox) {
119+
try {
120+
getOwnPropertyNames(nativePrototype);
121+
} catch (error) {
122+
nativePrototype = nativePrototype.__proto__;
123+
}
124+
}
118125
var wrapperConstructor = constructorTable.get(nativePrototype);
119126
if (wrapperConstructor) return wrapperConstructor;
120127
var parentWrapperConstructor = getWrapperConstructor(nativePrototype);
@@ -188,10 +195,11 @@ window.ShadowDOMPolyfill = {};
188195
if (descriptor.writable || descriptor.set || isBrokenSafari) {
189196
if (isEvent) setter = scope.getEventHandlerSetter(name); else setter = getSetter(name);
190197
}
198+
var configurable = isBrokenSafari || descriptor.configurable;
191199
defineProperty(target, name, {
192200
get: getter,
193201
set: setter,
194-
configurable: descriptor.configurable,
202+
configurable: configurable,
195203
enumerable: descriptor.enumerable
196204
});
197205
}
@@ -2028,7 +2036,10 @@ window.ShadowDOMPolyfill = {};
20282036
return index;
20292037
}
20302038
function shimSelector(selector) {
2031-
return String(selector).replace(/\/deep\//g, " ");
2039+
return String(selector).replace(/\/deep\/|::shadow/g, " ");
2040+
}
2041+
function shimMatchesSelector(selector) {
2042+
return String(selector).replace(/:host\(([^\s]+)\)/g, "$1").replace(/([^\s]):host/g, "$1").replace(":host", "*").replace(/\^|\/shadow\/|\/shadow-deep\/|::shadow|\/deep\/|::content/g, " ");
20322043
}
20332044
function findOne(node, selector) {
20342045
var m, el = node.firstElementChild;
@@ -2119,6 +2130,12 @@ window.ShadowDOMPolyfill = {};
21192130
return result;
21202131
}
21212132
};
2133+
var MatchesInterface = {
2134+
matches: function(selector) {
2135+
selector = shimMatchesSelector(selector);
2136+
return scope.originalMatches.call(unsafeUnwrap(this), selector);
2137+
}
2138+
};
21222139
function getElementsByTagNameFiltered(p, index, result, localName, lowercase) {
21232140
var target = unsafeUnwrap(this);
21242141
var list;
@@ -2173,6 +2190,7 @@ window.ShadowDOMPolyfill = {};
21732190
};
21742191
scope.GetElementsByInterface = GetElementsByInterface;
21752192
scope.SelectorsInterface = SelectorsInterface;
2193+
scope.MatchesInterface = MatchesInterface;
21762194
})(window.ShadowDOMPolyfill);
21772195

21782196
(function(scope) {
@@ -2299,6 +2317,10 @@ window.ShadowDOMPolyfill = {};
22992317

23002318
(function(scope) {
23012319
"use strict";
2320+
if (!window.DOMTokenList) {
2321+
console.warn("Missing DOMTokenList prototype, please include a " + "compatible classList polyfill such as http://goo.gl/uTcepH.");
2322+
return;
2323+
}
23022324
var unsafeUnwrap = scope.unsafeUnwrap;
23032325
var enqueueMutation = scope.enqueueMutation;
23042326
function getClass(el) {
@@ -2348,6 +2370,7 @@ window.ShadowDOMPolyfill = {};
23482370
var Node = scope.wrappers.Node;
23492371
var ParentNodeInterface = scope.ParentNodeInterface;
23502372
var SelectorsInterface = scope.SelectorsInterface;
2373+
var MatchesInterface = scope.MatchesInterface;
23512374
var addWrapNodeListMethod = scope.addWrapNodeListMethod;
23522375
var enqueueMutation = scope.enqueueMutation;
23532376
var mixin = scope.mixin;
@@ -2402,13 +2425,11 @@ window.ShadowDOMPolyfill = {};
24022425
enqueAttributeChange(this, name, oldValue);
24032426
invalidateRendererBasedOnAttribute(this, name);
24042427
},
2405-
matches: function(selector) {
2406-
return originalMatches.call(unsafeUnwrap(this), selector);
2407-
},
24082428
get classList() {
24092429
var list = classListTable.get(this);
24102430
if (!list) {
24112431
list = unsafeUnwrap(this).classList;
2432+
if (!list) return;
24122433
list.ownerElement_ = this;
24132434
classListTable.set(this, list);
24142435
}
@@ -2441,9 +2462,11 @@ window.ShadowDOMPolyfill = {};
24412462
mixin(Element.prototype, GetElementsByInterface);
24422463
mixin(Element.prototype, ParentNodeInterface);
24432464
mixin(Element.prototype, SelectorsInterface);
2465+
mixin(Element.prototype, MatchesInterface);
24442466
registerWrapper(OriginalElement, Element, document.createElementNS(null, "x"));
24452467
scope.invalidateRendererBasedOnAttribute = invalidateRendererBasedOnAttribute;
24462468
scope.matchesNames = matchesNames;
2469+
scope.originalMatches = originalMatches;
24472470
scope.wrappers.Element = Element;
24482471
})(window.ShadowDOMPolyfill);
24492472

@@ -3088,6 +3111,7 @@ window.ShadowDOMPolyfill = {};
30883111
var Element = scope.wrappers.Element;
30893112
var HTMLElement = scope.wrappers.HTMLElement;
30903113
var registerObject = scope.registerObject;
3114+
var defineWrapGetter = scope.defineWrapGetter;
30913115
var SVG_NS = "http://www.w3.org/2000/svg";
30923116
var svgTitleElement = document.createElementNS(SVG_NS, "title");
30933117
var SVGTitleElement = registerObject(svgTitleElement);
@@ -3097,6 +3121,7 @@ window.ShadowDOMPolyfill = {};
30973121
Object.defineProperty(HTMLElement.prototype, "classList", descr);
30983122
delete Element.prototype.classList;
30993123
}
3124+
defineWrapGetter(SVGElement, "ownerSVGElement");
31003125
scope.wrappers.SVGElement = SVGElement;
31013126
})(window.ShadowDOMPolyfill);
31023127

ShadowDOM.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build.log

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
BUILD LOG
22
---------
3-
Build Time: 2015-01-23T16:15:30-0800
3+
Build Time: 2015-02-13T14:44:07-0800
44

55
NODEJS INFORMATION
66
==================
7-
nodejs: v0.10.35
8-
gulp: 3.8.10
7+
nodejs: v0.12.0
8+
gulp: 3.8.11
99
gulp-audit: 1.0.0
1010
gulp-concat: 2.4.3
1111
gulp-header: 1.2.2
1212
gulp-uglify: 1.1.0
1313
run-sequence: 1.0.2
14-
web-component-tester: 2.0.5
14+
web-component-tester: 2.2.3
1515

1616
REPO REVISIONS
1717
==============
18-
webcomponentsjs: 9f91fd5d9d68a96821283869efac008535446218
18+
webcomponentsjs: 6c9c7173d6244689fbd01aa228c7ee3bce0935e2
1919

2020
BUILD HASHES
2121
============
22-
CustomElements.js: 4580193ee75072cb380d439fbf75a62deb9ca233
23-
CustomElements.min.js: 4b2c4f065126f25cfdf5f6c23f12169c9c18baa2
24-
HTMLImports.js: 736763ab217d150ccb625f42362fc03158fcaeb1
25-
HTMLImports.min.js: 7df544b9a6ac9f93dcdefa3eb6eaaea68c228967
26-
ShadowDOM.js: 1f6f01526cbc098563bf5b2d217090bf210a42f3
27-
ShadowDOM.min.js: 06f2ab5b486297bc9e3ce2a8b5cfe2130aa6ccbb
28-
webcomponents-lite.js: 644f816326e29842a8fb7cb0fa82636540d46257
29-
webcomponents-lite.min.js: 3f54f511045bd45d89df2c5bbcade19a242e2a64
30-
webcomponents.js: 9ea79ac36b5875de59b8277c5867bff72e3dab6c
31-
webcomponents.min.js: 97774057dcb06111606cf1b48623b7441a1d3f6a
22+
CustomElements.js: 1e6b7de46a4109a0d7c2dcc865ed7c7db668c2c2
23+
CustomElements.min.js: e06a4bec04e81ad4023797a612ab9acfc5af5d6c
24+
HTMLImports.js: 9ffdbb36b1ee9eecdb4af7538753c736120e6ea9
25+
HTMLImports.min.js: 5b367741ef44eccb58abddcbfc65ef9e7b32e37c
26+
ShadowDOM.js: cf222a7a0cfa9ae608bce5a0a6a87546079790de
27+
ShadowDOM.min.js: 159f5e228d15c8699fcd7dd0df68a435f998ec19
28+
webcomponents-lite.js: c0b2394b8f8e29e932a2fda7f6f8729d38b94c7d
29+
webcomponents-lite.min.js: 498bed532da4f6a14d6d0d3900fb5bf03b9d2fc7
30+
webcomponents.js: 4068a7d554816ca9490a837e253b0aabfcca9584
31+
webcomponents.min.js: 0a91336db9e17afc22a95003893450af22562e62

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "webcomponents.js",
33
"version": "0.5.4",
44
"description": "webcomponents.js",
5-
"main": "gulpfile.js",
5+
"main": "webcomponents.js",
66
"directories": {
77
"test": "tests"
88
},

webcomponents-lite.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,6 @@ if (typeof WeakMap === "undefined") {
358358
this.addTransientObserver(e.target);
359359

360360
case "DOMNodeInserted":
361-
var target = e.relatedNode;
362361
var changedNode = e.target;
363362
var addedNodes, removedNodes;
364363
if (e.type === "DOMNodeInserted") {
@@ -370,12 +369,12 @@ if (typeof WeakMap === "undefined") {
370369
}
371370
var previousSibling = changedNode.previousSibling;
372371
var nextSibling = changedNode.nextSibling;
373-
var record = getRecord("childList", target);
372+
var record = getRecord("childList", e.target.parentNode);
374373
record.addedNodes = addedNodes;
375374
record.removedNodes = removedNodes;
376375
record.previousSibling = previousSibling;
377376
record.nextSibling = nextSibling;
378-
forEachAncestorAndObserverEnqueueRecord(target, function(options) {
377+
forEachAncestorAndObserverEnqueueRecord(e.relatedNode, function(options) {
379378
if (!options.childList) return;
380379
return record;
381380
});
@@ -1010,12 +1009,15 @@ HTMLImports.addModule(function(scope) {
10101009
function isLinkRel(elt, rel) {
10111010
return elt.localName === "link" && elt.getAttribute("rel") === rel;
10121011
}
1012+
function hasBaseURIAccessor(doc) {
1013+
return !!Object.getOwnPropertyDescriptor(doc, "baseURI");
1014+
}
10131015
function makeDocument(resource, url) {
10141016
var doc = document.implementation.createHTMLDocument(IMPORT_LINK_TYPE);
10151017
doc._URL = url;
10161018
var base = doc.createElement("base");
10171019
base.setAttribute("href", url);
1018-
if (!doc.baseURI) {
1020+
if (!doc.baseURI && !hasBaseURIAccessor(doc)) {
10191021
Object.defineProperty(doc, "baseURI", {
10201022
value: url
10211023
});
@@ -1363,11 +1365,13 @@ CustomElements.addModule(function(scope) {
13631365
forDocumentTree(doc, upgradeDocument);
13641366
}
13651367
var originalCreateShadowRoot = Element.prototype.createShadowRoot;
1366-
Element.prototype.createShadowRoot = function() {
1367-
var root = originalCreateShadowRoot.call(this);
1368-
CustomElements.watchShadow(this);
1369-
return root;
1370-
};
1368+
if (originalCreateShadowRoot) {
1369+
Element.prototype.createShadowRoot = function() {
1370+
var root = originalCreateShadowRoot.call(this);
1371+
CustomElements.watchShadow(this);
1372+
return root;
1373+
};
1374+
}
13711375
scope.watchShadow = watchShadow;
13721376
scope.upgradeDocumentTree = upgradeDocumentTree;
13731377
scope.upgradeSubtree = addedSubtree;

0 commit comments

Comments
 (0)