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

8/1 master -> stable #29

Merged
merged 13 commits into from
Aug 1, 2013
95 changes: 52 additions & 43 deletions platform.js
Original file line number Diff line number Diff line change
@@ -1,62 +1,71 @@
/*
/*
* Copyright 2013 The Polymer Authors. All rights reserved.
* Use of this source code is governed by a BSD-style
* license that can be found in the LICENSE file.
*/

(function() {

var thisFile = 'platform.js';
var scopeName = 'Platform';

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

var ShadowDOMNative = [
'src/patches-shadowdom-native.js'
];
var ShadowDOMNative = [
'src/patches-shadowdom-native.js'
];

var ShadowDOMPolyfill = [
'../ShadowDOM/shadowdom.js',
'src/patches-shadowdom-polyfill.js',
'src/ShadowCSS.js'
];
var ShadowDOMPolyfill = [
'../ShadowDOM/shadowdom.js',
'src/patches-shadowdom-polyfill.js',
'src/ShadowCSS.js'
];

var Lib = [
'src/lang.js',
'src/dom.js',
'src/template.js',
'src/inspector.js',
];
var Lib = [
'src/lang.js',
'src/dom.js',
'src/template.js',
'src/inspector.js',
];

var MDV = [
'../mdv/mdv.js',
'src/patches-mdv.js'
];
var MDV = [
'../mdv/mdv.js',
'src/patches-mdv.js'
];

var Pointer = [
'../PointerGestures/pointergestures.js'
];
var Pointer = [
'../PointerGestures/pointergestures.js'
];

var WebElements = [
'../HTMLImports/html-imports.js',
'../CustomElements/custom-elements.js',
'src/patches-custom-elements.js'
];
var WebElements = [
'../HTMLImports/html-imports.js',
'../CustomElements/custom-elements.js',
'src/patches-custom-elements.js'
];

function processFlags(flags) {
flags.shadow = (flags.shadowdom || flags.shadow || flags.polyfill ||
!HTMLElement.prototype.webkitCreateShadowRoot) && 'polyfill';
var ShadowDOM = flags.shadow ? ShadowDOMPolyfill : ShadowDOMNative;
this.modules = [].concat(
ShadowDOM,
Lib,
WebElements,
Pointer,
MDV
);
// select ShadowDOM impl
var ShadowDOM = flags.shadow ? ShadowDOMPolyfill : ShadowDOMNative;

// construct active dependency list
this.modules = [].concat(
ShadowDOM,
Lib,
WebElements,
Pointer,
MDV
);
}
}

// export
// export

window[scopeName] = {
entryPointName: thisFile,
Expand All @@ -72,7 +81,7 @@ var basePath = src.slice(0, src.indexOf(thisFile));
if (!window.Loader) {
var path = basePath + 'tools/loader/loader.js';
document.write('<script src="' + path + '"></script>');
}
}
document.write('<script>Loader.load("' + scopeName + '")</script>');

})();
2 changes: 1 addition & 1 deletion src/ShadowCSS.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
becomes:


Alternatively, if Polymer.strictPolyfillStyling is set to true then
Alternatively, if Platform.ShadowCSS.strictStyling is set to true then
selectors are scoped by adding an attribute selector suffix to each
simple selector that contains the host element tag name. Each element
in the element's ShadowDOM template is also given the scope attribute.
Expand Down
13 changes: 2 additions & 11 deletions src/patches-mdv.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,9 @@ style.textContent = 'template {display: none !important;} /* injected by platfor
var head = document.querySelector('head');
head.insertBefore(style, head.firstChild);

// MDV hook for processing created dom before bindings are made. We upgrade
// so custom elements get a chance to deal with bindings mdv is about to make.
HTMLTemplateElement.__instanceCreated = function(inNode) {
// TODO(sorvell): workaround for
// https://code.google.com/p/chromium/issues/detail?id=229125
document.adoptNode(inNode);
CustomElements.upgradeAll(inNode);
};

// dirtyCheck (with logging)
function dirtyCheck() {
logFlags.data && console.group("Model.dirtyCheck()");
logFlags.data && console.group("Platform.performMicrotaskCheckpoint()");
check();
logFlags.data && console.groupEnd();
};
Expand All @@ -45,7 +36,7 @@ window.addEventListener('WebComponentsReady', function() {

// dirty check periodically if platform does not have object observe.
if (!Observer.hasObjectObserve) {
setInterval(check, dirtyCheckPollInterval);
scope.dirtyPoll = setInterval(check, dirtyCheckPollInterval);
}
});

Expand Down
10 changes: 10 additions & 0 deletions src/patches-shadowdom-native.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@
window.wrap = window.unwrap = function(n){
return n;
}

var originalCreateShadowRoot = HTMLElement.prototype.webkitCreateShadowRoot;
HTMLElement.prototype.webkitCreateShadowRoot = function() {
var elderRoot = this.webkitShadowRoot;
var root = originalCreateShadowRoot.call(this);
root.olderShadowRoot = elderRoot;
root.host = this;
CustomElements.watchShadow(this);
return root;
}

Object.defineProperties(HTMLElement.prototype, {
shadowRoot: {
Expand Down
8 changes: 8 additions & 0 deletions src/patches-shadowdom-polyfill.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@
}
}
});

// include .host reference
var originalCreateShadowRoot = HTMLElement.prototype.createShadowRoot;
HTMLElement.prototype.createShadowRoot = function() {
var root = originalCreateShadowRoot.call(this);
root.host = this;
return root;
}

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