Skip to content
This repository was archived by the owner on Mar 13, 2018. It is now read-only.

Commit 92b34ea

Browse files
committed
Merge pull request #29 from Polymer/master
8/1 master -> stable
2 parents 4405830 + 7f95f08 commit 92b34ea

5 files changed

Lines changed: 73 additions & 55 deletions

File tree

platform.js

Lines changed: 52 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,71 @@
1-
/*
1+
/*
22
* Copyright 2013 The Polymer Authors. All rights reserved.
33
* Use of this source code is governed by a BSD-style
44
* license that can be found in the LICENSE file.
55
*/
66

77
(function() {
8-
8+
99
var thisFile = 'platform.js';
1010
var scopeName = 'Platform';
1111

12-
// module dependencies
12+
function processFlags(flags) {
13+
if (flags.build) {
14+
// use the minified build
15+
this.modules = ['platform.min.js'];
16+
} else {
17+
// truthy value for any of these flags or failure to detect native
18+
// shadowDOM results in polyfill
19+
flags.shadow = (flags.shadowdom || flags.shadow || flags.polyfill ||
20+
!HTMLElement.prototype.webkitCreateShadowRoot) && 'polyfill';
1321

14-
var ShadowDOMNative = [
15-
'src/patches-shadowdom-native.js'
16-
];
22+
var ShadowDOMNative = [
23+
'src/patches-shadowdom-native.js'
24+
];
1725

18-
var ShadowDOMPolyfill = [
19-
'../ShadowDOM/shadowdom.js',
20-
'src/patches-shadowdom-polyfill.js',
21-
'src/ShadowCSS.js'
22-
];
26+
var ShadowDOMPolyfill = [
27+
'../ShadowDOM/shadowdom.js',
28+
'src/patches-shadowdom-polyfill.js',
29+
'src/ShadowCSS.js'
30+
];
2331

24-
var Lib = [
25-
'src/lang.js',
26-
'src/dom.js',
27-
'src/template.js',
28-
'src/inspector.js',
29-
];
32+
var Lib = [
33+
'src/lang.js',
34+
'src/dom.js',
35+
'src/template.js',
36+
'src/inspector.js',
37+
];
3038

31-
var MDV = [
32-
'../mdv/mdv.js',
33-
'src/patches-mdv.js'
34-
];
39+
var MDV = [
40+
'../mdv/mdv.js',
41+
'src/patches-mdv.js'
42+
];
3543

36-
var Pointer = [
37-
'../PointerGestures/pointergestures.js'
38-
];
44+
var Pointer = [
45+
'../PointerGestures/pointergestures.js'
46+
];
3947

40-
var WebElements = [
41-
'../HTMLImports/html-imports.js',
42-
'../CustomElements/custom-elements.js',
43-
'src/patches-custom-elements.js'
44-
];
48+
var WebElements = [
49+
'../HTMLImports/html-imports.js',
50+
'../CustomElements/custom-elements.js',
51+
'src/patches-custom-elements.js'
52+
];
4553

46-
function processFlags(flags) {
47-
flags.shadow = (flags.shadowdom || flags.shadow || flags.polyfill ||
48-
!HTMLElement.prototype.webkitCreateShadowRoot) && 'polyfill';
49-
var ShadowDOM = flags.shadow ? ShadowDOMPolyfill : ShadowDOMNative;
50-
this.modules = [].concat(
51-
ShadowDOM,
52-
Lib,
53-
WebElements,
54-
Pointer,
55-
MDV
56-
);
54+
// select ShadowDOM impl
55+
var ShadowDOM = flags.shadow ? ShadowDOMPolyfill : ShadowDOMNative;
56+
57+
// construct active dependency list
58+
this.modules = [].concat(
59+
ShadowDOM,
60+
Lib,
61+
WebElements,
62+
Pointer,
63+
MDV
64+
);
65+
}
5766
}
5867

59-
// export
68+
// export
6069

6170
window[scopeName] = {
6271
entryPointName: thisFile,
@@ -72,7 +81,7 @@ var basePath = src.slice(0, src.indexOf(thisFile));
7281
if (!window.Loader) {
7382
var path = basePath + 'tools/loader/loader.js';
7483
document.write('<script src="' + path + '"></script>');
75-
}
84+
}
7685
document.write('<script>Loader.load("' + scopeName + '")</script>');
77-
86+
7887
})();

src/ShadowCSS.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
becomes:
5858
5959
60-
Alternatively, if Polymer.strictPolyfillStyling is set to true then
60+
Alternatively, if Platform.ShadowCSS.strictStyling is set to true then
6161
selectors are scoped by adding an attribute selector suffix to each
6262
simple selector that contains the host element tag name. Each element
6363
in the element's ShadowDOM template is also given the scope attribute.

src/patches-mdv.js

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,9 @@ style.textContent = 'template {display: none !important;} /* injected by platfor
1111
var head = document.querySelector('head');
1212
head.insertBefore(style, head.firstChild);
1313

14-
// MDV hook for processing created dom before bindings are made. We upgrade
15-
// so custom elements get a chance to deal with bindings mdv is about to make.
16-
HTMLTemplateElement.__instanceCreated = function(inNode) {
17-
// TODO(sorvell): workaround for
18-
// https://code.google.com/p/chromium/issues/detail?id=229125
19-
document.adoptNode(inNode);
20-
CustomElements.upgradeAll(inNode);
21-
};
22-
2314
// dirtyCheck (with logging)
2415
function dirtyCheck() {
25-
logFlags.data && console.group("Model.dirtyCheck()");
16+
logFlags.data && console.group("Platform.performMicrotaskCheckpoint()");
2617
check();
2718
logFlags.data && console.groupEnd();
2819
};
@@ -45,7 +36,7 @@ window.addEventListener('WebComponentsReady', function() {
4536

4637
// dirty check periodically if platform does not have object observe.
4738
if (!Observer.hasObjectObserve) {
48-
setInterval(check, dirtyCheckPollInterval);
39+
scope.dirtyPoll = setInterval(check, dirtyCheckPollInterval);
4940
}
5041
});
5142

src/patches-shadowdom-native.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@
1515
window.wrap = window.unwrap = function(n){
1616
return n;
1717
}
18+
19+
var originalCreateShadowRoot = HTMLElement.prototype.webkitCreateShadowRoot;
20+
HTMLElement.prototype.webkitCreateShadowRoot = function() {
21+
var elderRoot = this.webkitShadowRoot;
22+
var root = originalCreateShadowRoot.call(this);
23+
root.olderShadowRoot = elderRoot;
24+
root.host = this;
25+
CustomElements.watchShadow(this);
26+
return root;
27+
}
1828

1929
Object.defineProperties(HTMLElement.prototype, {
2030
shadowRoot: {

src/patches-shadowdom-polyfill.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@
4343
}
4444
}
4545
});
46+
47+
// include .host reference
48+
var originalCreateShadowRoot = HTMLElement.prototype.createShadowRoot;
49+
HTMLElement.prototype.createShadowRoot = function() {
50+
var root = originalCreateShadowRoot.call(this);
51+
root.host = this;
52+
return root;
53+
}
4654

4755
//TODO(sjmiles): review method alias with Arv
4856
HTMLElement.prototype.webkitCreateShadowRoot =

0 commit comments

Comments
 (0)