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

Commit 8645fe5

Browse files
committed
Merge pull request #35 from Polymer/master
8/15 master -> stable
2 parents 90d76ed + 4fe7bb6 commit 8645fe5

14 files changed

+122
-64
lines changed

conf/karma.conf.js

+8-5
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,14 @@ module.exports = function(karma) {
2020
{pattern: 'CustomElements/src/*.js', included: false},
2121
{pattern: 'HTMLImports/html-imports.js', included: false},
2222
{pattern: 'HTMLImports/src/*', included: false},
23-
{pattern: 'mdv/mdv.js', included: false},
24-
{pattern: 'mdv/src/*', included: false},
25-
{pattern: 'mdv/third_party/**/*.js', included: false},
26-
{pattern: 'mdv/util/*.js', included: false},
27-
{pattern: 'mdv/tests/*.js', included: false},
23+
{pattern: 'observe-js/src/observe.js', included: false},
24+
{pattern: 'observe-js/tests/*.js', included: false},
25+
{pattern: 'NodeBind/src/NodeBind.js', included: false},
26+
{pattern: 'NodeBind/tests/*.js', included: false},
27+
{pattern: 'TemplateInstances/src/TemplateInstances.js', included: false},
28+
{pattern: 'TemplateInstances/tests/*.js', included: false},
29+
{pattern: 'polymer-expressions/src/*', included: false},
30+
{pattern: 'polymer-expressions/tests/*.js', included: false},
2831
{pattern: 'ShadowDOM/shadowdom.js', included: false},
2932
{pattern: 'ShadowDOM/src/**/*.js', included: false},
3033
{pattern: 'PointerEvents/pointerevents.js', included: false},

gruntfile.js

+10-12
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@ module.exports = function(grunt) {
2727
'wrappers/generic.js',
2828
'wrappers/ShadowRoot.js',
2929
'ShadowRenderer.js',
30+
'wrappers/elements-with-form-property.js',
3031
'wrappers/Document.js',
3132
'wrappers/Window.js',
3233
'wrappers/MutationObserver.js',
34+
'wrappers/Range.js',
3335
'wrappers/override-constructors.js'
3436
];
3537
ShadowDOMPolyfill = ShadowDOMPolyfill.map(function(p) {
@@ -48,18 +50,13 @@ module.exports = function(grunt) {
4850
];
4951

5052
MDV = [
51-
'third_party/ChangeSummary/change_summary.js',
52-
'src/template_element.js',
53-
'third_party/esprima/esprima.js',
54-
'util/expression_syntax.js'
55-
];
56-
MDV = MDV.map(function(p) {
57-
return '../mdv/' + p;
58-
});
59-
60-
MDV.push(
53+
'../observe-js/src/observe.js',
54+
'../NodeBind/src/NodeBind.js',
55+
'../TemplateBinding/src/TemplateBinding.js',
56+
'../polymer-expressions/third_party/esprima/esprima.js',
57+
'../polymer-expressions/src/polymer-expressions.js',
6158
'src/patches-mdv.js'
62-
);
59+
];
6360

6461
PointerEvents = [
6562
'boot.js',
@@ -108,7 +105,8 @@ module.exports = function(grunt) {
108105
'../CustomElements/src/HTMLElementElement.js',
109106
'../CustomElements/src/Parser.js',
110107
'../CustomElements/src/boot.js',
111-
'src/patches-custom-elements.js'
108+
'src/patches-custom-elements.js',
109+
'src/microtask.js'
112110
];
113111

114112
Main = [].concat(

platform.js

+13-8
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ function processFlags(flags) {
1414
// use the minified build
1515
this.modules = ['platform.min.js'];
1616
} else {
17-
// truthy value for any of these flags or failure to detect native
18-
// shadowDOM results in polyfill
17+
// truthy value for any of these flags, or failure to detect native
18+
// ShadowDOM, results in polyfill
1919
flags.shadow = (flags.shadowdom || flags.shadow || flags.polyfill ||
20-
!HTMLElement.prototype.webkitCreateShadowRoot) && 'polyfill';
20+
!HTMLElement.prototype.webkitCreateShadowRoot) && 'polyfill';
2121

2222
var ShadowDOMNative = [
2323
'src/patches-shadowdom-native.js'
@@ -33,11 +33,15 @@ function processFlags(flags) {
3333
'src/lang.js',
3434
'src/dom.js',
3535
'src/template.js',
36-
'src/inspector.js',
36+
'src/inspector.js'
3737
];
3838

3939
var MDV = [
40-
'../mdv/mdv.js',
40+
'../observe-js/src/observe.js',
41+
'../NodeBind/src/NodeBind.js',
42+
'../TemplateBinding/src/TemplateBinding.js',
43+
'../polymer-expressions/third_party/esprima/esprima.js',
44+
'../polymer-expressions/src/polymer-expressions.js',
4145
'src/patches-mdv.js'
4246
];
4347

@@ -48,7 +52,8 @@ function processFlags(flags) {
4852
var WebElements = [
4953
'../HTMLImports/html-imports.js',
5054
'../CustomElements/custom-elements.js',
51-
'src/patches-custom-elements.js'
55+
'src/patches-custom-elements.js',
56+
'src/microtask.js'
5257
];
5358

5459
// select ShadowDOM impl
@@ -78,10 +83,10 @@ var script = document.querySelector('script[src*="' + thisFile + '"]');
7883
var src = script.attributes.src.value;
7984
var basePath = src.slice(0, src.indexOf(thisFile));
8085

81-
if (!window.Loader) {
86+
if (!window.PolymerLoader) {
8287
var path = basePath + 'tools/loader/loader.js';
8388
document.write('<script src="' + path + '"></script>');
8489
}
85-
document.write('<script>Loader.load("' + scopeName + '")</script>');
90+
document.write('<script>PolymerLoader.load("' + scopeName + '")</script>');
8691

8792
})();

src/ShadowCSS.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,8 @@ var ShadowCSS = {
174174
def.rootStyles = styles;
175175
def.scopeStyles = def.rootStyles;
176176
var extendee = this.registry[def.extendsName];
177-
if (extendee) {
178-
def.scopeStyles = def.scopeStyles.concat(extendee.scopeStyles);
177+
if (extendee && root.querySelector('shadow')) {
178+
def.scopeStyles = extendee.scopeStyles.concat(def.scopeStyles);
179179
}
180180
return def;
181181
},

src/microtask.js

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Copyright 2013 The Polymer Authors. All rights reserved.
3+
* Use of this source code is governed by a BSD-style
4+
* license that can be found in the LICENSE file.
5+
*/
6+
(function(scope) {
7+
8+
var iterations = 0;
9+
var callbacks = [];
10+
var twiddle = document.createTextNode('');
11+
function eomt(callback) {
12+
twiddle.textContent = iterations++;
13+
callbacks.push(callback);
14+
}
15+
var MO = window.MutationObserver || window.JsMutationObserver;
16+
new MO(function() {
17+
while (callbacks.length) {
18+
callbacks.shift()();
19+
}
20+
}).observe(twiddle, {characterData: true});
21+
22+
// exports
23+
scope.endOfMicrotask = eomt;
24+
25+
})(window.Platform);
26+

src/patches-mdv.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function dirtyCheck() {
2020

2121
// call notifyChanges in Model scope
2222
function check() {
23-
Platform.performMicrotaskCheckpoint();
23+
scope.endOfMicrotask(Platform.performMicrotaskCheckpoint);
2424
};
2525

2626
var dirtyCheckPollInterval = 125;
@@ -41,7 +41,6 @@ window.addEventListener('WebComponentsReady', function() {
4141
});
4242

4343
// exports
44-
4544
scope.flush = dirtyCheck;
4645

4746
// deprecated

test/html/includes/import-file.html

-13
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,3 @@
1-
<!DOCTYPE html>
2-
<!--
3-
Copyright 2013 The Polymer Authors. All rights reserved.
4-
Use of this source code is governed by a BSD-style
5-
license that can be found in the LICENSE file.
6-
-->
7-
<element name='import-test'>
8-
<script>
9-
this.register({prototype: {
10-
ready: true
11-
}})
12-
</script>
13-
</element>
141
<script>
152
window.importTest = true;
163
</script>

test/html/mdv-shadow.html

+17-5
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,24 @@
1010
<title>MDV + ShadowDOM Polyfill Integration Tests</title>
1111
<link rel="stylesheet" href="../../node_modules/mocha/mocha.css">
1212
<script src="../../../ShadowDOM/shadowdom.js"></script>
13+
<script>
14+
var parserHasNativeTemplate = function() {
15+
var div = document.createElement('div');
16+
div.innerHTML = '<table><template>';
17+
return div.firstChild.firstChild &&
18+
div.firstChild.firstChild.tagName == 'TEMPLATE';
19+
}();
20+
21+
var forceCollectObservers = true;
22+
</script>
1323
<script src="../../node_modules/mocha/mocha.js"></script>
1424
<script src="../../node_modules/chai/chai.js"></script>
1525
<script src="../../tools/test/htmltest.js"></script>
16-
<script src="../../../mdv/tests/setup.js"></script>
17-
<script src="../../../mdv/mdv.js"></script>
26+
<script src="../../../observe-js/src/observe.js"></script>
27+
<script src="../../../NodeBind/src/NodeBind.js"></script>
28+
<script src="../../../polymer-expressions/src/polymer-expressions.js"></script>
29+
<script src="../../../polymer-expressions/third_party/esprima/esprima.js"></script>
30+
<script src="../../../TemplateInstances/src/TemplateInstances.js"></script>
1831
</head>
1932
<body>
2033
<script>
@@ -27,9 +40,8 @@
2740
var assert = chai.assert;
2841

2942
</script>
30-
<!-- <script src="../../../mdv/tests/node_bindings.js"></script> -->
31-
<script src="../../../mdv/tests/template_element.js"></script>
32-
<script src="../../../mdv/tests/expression_syntax.js"></script>
43+
<script src="../../../polymer-expressions/tests/tests.js"></script>
44+
<script src="../../../TemplateInstances/tests/tests.js"></script>
3345
<div id="mocha"></div>
3446
<script>
3547
var unwrap = ShadowDOMPolyfill.unwrap;

test/html/smoke.html

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,25 @@
1919
var assert = chai.assert;
2020
window.addEventListener('WebComponentsReady', function() {
2121
var p = Object.create(HTMLElement.prototype);
22-
p.readyCallback = function() {
22+
p.createdCallback = function() {
2323
this.textContent = 'custom!';
2424
}
2525
document.register('x-foo', {prototype: p});
2626
//
2727
var p = Object.create(HTMLButtonElement.prototype);
28-
p.readyCallback = function() {
28+
p.createdCallback = function() {
2929
this.textContent = 'custom!';
3030
}
3131
document.register('x-baz', {prototype: p, extends: 'button'});
32-
document.body.appendChild(document.createElement('x-baz')).id = 'baz2';
32+
document.body.appendChild(document.createElement('button', 'x-baz')).id = 'baz2';
3333
//
3434
assert.equal(document.querySelector('x-foo').textContent, 'custom!',
3535
'x-foo must have custom text');
3636
//
3737
assert.equal(document.querySelector('[is=x-baz]').textContent,
3838
'custom!', 'button is="x-baz" must have custom text');
3939
assert.equal(document.querySelector('#baz2').textContent, 'custom!',
40-
'x-baz must have custom text');
40+
'button is=x-baz can be created via document.createElement(button, x-baz)');
4141
//
4242
done();
4343
});

test/html/styling/host.html

+31-2
Original file line numberDiff line numberDiff line change
@@ -88,19 +88,31 @@
8888
@host {
8989
* {
9090
padding: 20px;
91+
border-top-color: brown;
9192
}
9293
}
9394
</style>
9495
<shadow></shadow>
9596
<div>padding: 20px</div>
9697
</template>
9798

99+
<template id="x-zim2">
100+
<style>
101+
@host {
102+
* {
103+
padding: 20px;
104+
}
105+
}
106+
</style>
107+
<div>padding: 20px</div>
108+
</template>
98109

99110
<script>
100111
XFoo = register('x-foo', '', HTMLElement.prototype, ['x-foo']);
101112
XBar = register('x-bar', 'x-foo', XFoo.prototype, ['x-foo', 'x-bar']);
102113
XZot = register('x-zot', 'x-bar', XBar.prototype, ['x-foo', 'x-bar', 'x-zot']);
103114
XZim = register('x-zim', 'x-zot', XZot.prototype, ['x-foo', 'x-bar', 'x-zot', 'x-zim']);
115+
XZim2 = register('x-zim2', 'x-zot', XZot.prototype, ['x-foo', 'x-bar', 'x-zot', 'x-zim2']);
104116
register('x-scope', '', HTMLElement.prototype, ['x-scope']);
105117
register('x-button', '', HTMLButtonElement.prototype, ['x-button']);
106118
</script>
@@ -128,6 +140,9 @@ <h4>Expected: red background with black text and orange border</h4>
128140

129141
<h4>Expected: red background with black text and orange border and 20px padding</h4>
130142
<x-zim></x-zim>
143+
144+
<h4>Expected: 20px padding</h4>
145+
<x-zim2></x-zim2>
131146

132147
<script>
133148
document.addEventListener('WebComponentsReady', function() {
@@ -168,18 +183,32 @@ <h4>Expected: red background with black text and orange border and 20px padding<
168183
chai.assert.equal(zimStyle.backgroundColor, 'rgb(255, 0, 0)',
169184
'@host styles are inherited (backgroundColor)');
170185

171-
chai.assert.equal(zimStyle.borderTopColor, 'rgb(255, 165, 0)',
186+
chai.assert.equal(zimStyle.borderTopColor, 'rgb(165, 42, 42)',
172187
'@host styles are combined with inherited @host styles (borderTopColor)');
173188
chai.assert.equal(zimStyle.borderBottomColor, 'rgb(255, 165, 0)',
174189
'@host styles are combined with inherited @host styles (borderBottomColor)');
175190
chai.assert.equal(zimStyle.color, 'rgb(0, 0, 0)',
176191
'@host styles are applied to given selector (color)');
177192
chai.assert.equal(zimStyle.paddingTop, '20px',
178193
'@host styles are loaded via external sheet in import (paddingTop)');
179-
chai.assert.equal(zimStyle.paddingLeft, '20px',
194+
chai.assert.equal(zimStyle.paddingLeft, '20px',
180195
'@host styles are loaded via external sheet in import (paddingLeft)');
181196
zim.offsetHeight;
197+
198+
var zim2 = document.querySelector('x-zim2');
199+
var zimStyle2 = getComputedStyle(zim2);
200+
chai.assert.equal(zimStyle2.borderTopColor, 'rgb(0, 0, 0)',
201+
'@host styles are not combined without <shadow> (borderTopColor)');
202+
chai.assert.equal(zimStyle2.borderBottomColor, 'rgb(0, 0, 0)',
203+
'@host styles are not combined without <shadow> (borderBottomColor)');
204+
chai.assert.equal(zimStyle2.paddingTop, '20px',
205+
'@host styles are loaded via external sheet in import (paddingTop)');
206+
chai.assert.equal(zimStyle2.paddingLeft, '20px',
207+
'@host styles are loaded via external sheet in import (paddingLeft)');
208+
182209
done();
210+
211+
183212
});
184213
</script>
185214
</body>

test/html/styling/register.js

+7-6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
}
77
var ctor = document.register(name, {
88
prototype: Object.create(proto, {
9-
readyCallback: {
9+
createdCallback: {
1010
value: function() {
1111
if (templates) {
1212
templates.forEach(function(t) {
@@ -24,12 +24,13 @@
2424
}
2525

2626
function shim(templates, name, extnds) {
27-
templates.forEach(function(templateName) {
28-
var template = document.querySelector('#' + templateName);
27+
if (templates) {
28+
var id = templates[templates.length - 1];
29+
var template = document.querySelector('#' + id);
2930
if (template) {
30-
Platform.ShadowCSS.shimStyling(template.content, name, extnds);
31-
}
32-
});
31+
Platform.ShadowCSS.shimStyling(template.content, name, extnds);
32+
}
33+
}
3334
}
3435

3536
scope.register = register;

test/html/web-components.html

-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
window.addEventListener('WebComponentsReady', function() {
2222
chai.assert.ok(window.importsOk, 'WebComponentsReady without HTMLImportsLoaded');
2323
chai.assert.ok(window.importTest, 'import failed to set global value');
24-
var elt = document.createElement('import-test');
25-
chai.assert.ok(elt.ready, 'import failed to register custom element');
2624
done();
2725
});
2826
</script>

test/js/tests.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ htmlSuite('integration', function() {
1515
htmlTest('html/web-components.html');
1616
htmlTest('html/smoke.html');
1717
htmlTest('html/smoke.html?shadow=polyfill');
18-
htmlTest('html/strawkit.html');
19-
htmlTest('html/strawkit.html?shadow=polyfill');
18+
//htmlTest('html/strawkit.html');
19+
//htmlTest('html/strawkit.html?shadow=polyfill');
2020
htmlTest('html/mdv-shadow.html');
2121
//htmlTest('html/html-import-sandbox.html');
2222
});

0 commit comments

Comments
 (0)