Merge branch 'master' into style-fixes

Conflicts:
	test/unit/styling-scoped-elements.html
	test/unit/styling-scoped.html

+ fix test on Safari that uses computed url style.
This commit is contained in:
Steven Orvell 2016-02-12 17:50:02 -08:00
commit f8289fec8c
43 changed files with 634 additions and 467 deletions

View File

@ -1,5 +1,4 @@
node_modules/*
bower_components/*
test/*
src/**/demo/*
src/**/experimental/*

View File

@ -14,8 +14,8 @@ addons:
before_script:
- npm install -g bower
- bower install
script:
- gulp lint
script:
- xvfb-run wct
- "if [ \"${TRAVIS_PULL_REQUEST}\" = \"false\" ]; then wct -s 'default'; fi"
env:

View File

@ -127,7 +127,7 @@ gulp.task('release', function(cb) {
});
gulp.task('lint', function() {
return gulp.src('src/**/*.html')
return gulp.src(['src/**/*.html', 'test/unit/*.html'])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());

View File

@ -143,7 +143,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
var EFFECT_ORDER = {
'compute': 0,
'annotation': 1,
'computedAnnotation': 2,
'annotatedComputation': 2,
'reflect': 3,
'notify': 4,
'observer': 5,

View File

@ -149,12 +149,13 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
if (m) {
p = this.valueForProperty(props[m[1]], props);
} else {
var pp = p.split(':');
if (pp[1]) {
pp[1] = pp[1].trim();
pp[1] = this.valueForProperty(pp[1], props) || pp[1];
var colon = p.indexOf(':');
if (colon !== -1) {
var pp = p.substring(colon);
pp = pp.trim();
pp = this.valueForProperty(pp, props) || pp;
p = p.substring(0, colon) + pp;
}
p = pp.join(':');
}
parts[i] = (p && p.lastIndexOf(';') === p.length - 1) ?
// strip trailing ;
@ -443,7 +444,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
// var(--a, --b)
// var(--a, fallback-literal)
// var(--a, fallback-literal(with-one-nested-parentheses))
VAR_MATCH: /(^|\W+)var\([\s]*([^,)]*)[\s]*,?[\s]*((?:[^,)]*)|(?:[^;]*\([^;)]*\)))[\s]*?\)/gi,
VAR_MATCH: /(^|\W+)var\([\s]*([^,)]*)[\s]*,?[\s]*((?:[^,()]*)|(?:[^;()]*\([^;)]*\)))[\s]*?\)/gi,
VAR_CAPTURE: /\([\s]*(--[^,\s)]*)(?:,[\s]*(--[^,\s)]*))?(?:\)|,)/gi,
ANIMATION_MATCH: /(animation\s*:)|(animation-name\s*:)/,
IS_VAR: /^--/,

View File

@ -231,7 +231,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
_scopeElementClass: function(element, selector) {
if (!nativeShadow && !this._scopeCssViaAttr) {
selector += (selector ? ' ' : '') + SCOPE_NAME + ' ' + this.is +
selector = (selector ? selector + ' ' : '') + SCOPE_NAME + ' ' + this.is +
(element._scopeSelector ? ' ' + XSCOPE_NAME + ' ' +
element._scopeSelector : '');
}

3
test/.eslintignore Normal file
View File

@ -0,0 +1,3 @@
assets/*
compat/*
smoke/*

10
test/.eslintrc.json Normal file
View File

@ -0,0 +1,10 @@
{
"env": {
"mocha": true
},
"globals": {
"assert": true,
"sinon": true,
"WCT": true
}
}

View File

@ -32,10 +32,10 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
</template>
<script>
/* global bind observer singleBound multiBound */
suite('basic', function() {
test('single selection', function() {
var el = singleConfigured;
var el = document.querySelector('#singleConfigured');
// Nothing selected
assert.strictEqual(el.selectedItem, null);
assert.isFalse(el.isSelected(el.items[0]));
@ -76,7 +76,7 @@ suite('basic', function() {
});
test('multiple selection', function() {
var el = multiConfigured;
var el = document.querySelector('#multiConfigured');
// Nothing selected
assert.sameMembers(el.selected, []);
assert.isFalse(el.isSelected(el.items[0]));
@ -143,7 +143,7 @@ suite('basic', function() {
};
singleBound.select(bind.items[2]);
assert.equal(called, true);
observer.singleChanged = function(info) {};
observer.singleChanged = function() {};
});
test('single selection sub-property change', function() {
@ -156,7 +156,7 @@ suite('basic', function() {
};
bind.set(['items', 2, 'name'], 'test');
assert.equal(called, true);
observer.singleChanged = function(info) {};
observer.singleChanged = function() {};
});
test('single selection sub-property change after unshift', function() {
@ -170,7 +170,7 @@ suite('basic', function() {
bind.unshift('items', {name: 'zero'});
bind.set(['items', 3, 'name'], 'test2');
assert.equal(called, true);
observer.singleChanged = function(info) {};
observer.singleChanged = function() {};
});
test('multi selection notification', function() {
@ -210,7 +210,7 @@ suite('basic', function() {
};
multiBound.select(bind.items[0]);
assert.equal(called, true);
observer.multiChanged = function(info) {};
observer.multiChanged = function() {};
});
test('multi selection sub-property change', function() {
@ -230,7 +230,7 @@ suite('basic', function() {
};
bind.set(['items', 0, 'name'], 'test2');
assert.equal(called, true);
observer.multiChanged = function(info) {};
observer.multiChanged = function() {};
});

View File

@ -19,7 +19,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
<body>
<script>
/* global Async */
setup(function() {
window.Async = Polymer.Async;
});
@ -191,7 +191,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
called3++;
};
var h1 = Async.run(callback1);
var h2 = Async.run(callback2);
var h2 = Async.run(callback2); //eslint-disable-line no-unused-vars
var h3 = Async.run(callback3);
Async.cancel(h1);
Async.cancel(h3);
@ -306,7 +306,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
called3++;
};
var h1 = Async.run(callback1, 50);
var h2 = Async.run(callback2, 50);
var h2 = Async.run(callback2, 50); //eslint-disable-line no-unused-vars
var h3 = Async.run(callback3, 200);
Async.cancel(h1);
Async.cancel(h3);

View File

@ -1,32 +1,32 @@
<!--
@license
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
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
-->
<dom-module id="attached-style">
<style>
:host {
display: block;
box-sizing: border-box;
border: 1px solid black;
height: 100px;
}
</style>
<template>Hi</template>
<script>
Polymer({
is: 'attached-style',
attached: function() {
this.offsetParentAtAttachedTime = this.offsetParent;
this.offsetHeightAtAttachedTime = this.offsetHeight;
}
});
</script>
</dom-module>
<!--
@license
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
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
-->
<dom-module id="attached-style">
<style>
:host {
display: block;
box-sizing: border-box;
border: 1px solid black;
height: 100px;
}
</style>
<template>Hi</template>
<script>
Polymer({
is: 'attached-style',
attached: function() {
this.offsetParentAtAttachedTime = this.offsetParent;
this.offsetHeightAtAttachedTime = this.offsetHeight;
}
});
</script>
</dom-module>

View File

@ -65,14 +65,14 @@
propChangedCount: 0,
attr1ChangedCount: 0,
propChanged: function(prop) {
propChanged: function() {
this.propChangedCount++;
},
attr1Changed: function(prop) {
attr1Changed: function() {
this.attr1ChangedCount++;
}
});
</script>
@ -154,4 +154,4 @@
this.setAttribute('prop2', 'hi');
}
});
</script>
</script>

View File

@ -55,6 +55,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
</x-reflect>
<script>
/* global basicDefault basicConfigured compose reflectDefault reflectConfigured */
var configuredObject = {foo: 'bar', nested: {'meaning': 42}, arr: [0, 'foo', true]};
var configuredArray = [0, 'foo', true, {foo: 'bar'}];

View File

@ -29,6 +29,7 @@ var instance;
setup(function() {
// Ensure a clean environment for each test.
/* global Base */
window.Base = Polymer.Base;
window.Child = Object.create(Base);
Child._registerFeatures = function() {};

View File

@ -90,7 +90,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
overridablePropertyB: {
value: true
},
}
},
@ -102,7 +102,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
_simpleProperty: 'B',
_disabledChanged: function(disabled) {
this.__disabled = disabled
this.__disabled = disabled;
},
ready: function() {

View File

@ -492,3 +492,93 @@
});
</script>
</dom-module>
<dom-module id="x-order-of-effects-grand-parent">
<template>
<x-order-of-effects id="child" base="{{base}}"></x-order-of-effects>
</template>
</dom-module>
<dom-module id="x-order-of-effects">
<template>
<x-order-of-effects-child
prop1="[[base]]"
prop2="[[_computedAnnotation(base)]]"
></x-order-of-effects-child>
</template>
<script>
(function() {
var invocations = [];
Polymer({
is: 'x-order-of-effects-grand-parent',
properties: {
base: {
observer: '_childPropertyChanged'
}
},
_childPropertyChanged: function() {
invocations.push('notify');
}
});
Polymer({
is: 'x-order-of-effects',
properties: {
base: {
type: String,
observer: '_observer',
notify: true,
reflectToAttribute: true
},
computed: {
type: String,
computed: '_computed(base)'
},
complex: {
type: String,
value: 'complex'
}
},
observers: ['_complexObserver(complex, base)'],
ready: function() {
this.invocations = invocations;
var old = this.reflectPropertyToAttribute.bind(this);
this.reflectPropertyToAttribute = function(property, attribute, value) {
invocations.push('reflect');
old(property, attribute, value);
};
},
_computed: function(base) {
invocations.push('compute');
return base;
},
_computedAnnotation: function(base) {
return base;
},
_observer: function() {
invocations.push('observer');
},
_complexObserver: function() {
invocations.push('complexObserver');
}
});
Polymer({
is: 'x-order-of-effects-child',
properties: {
prop1: {
observer: '_prop1Changed'
},
prop2: {
observer: '_prop2Changed'
}
},
_prop1Changed: function() {
invocations.push('annotation');
},
_prop2Changed: function() {
invocations.push('annotatedComputation');
}
});
})();
</script>
</dom-module>

View File

@ -132,7 +132,7 @@ suite('single-element binding effects', function() {
test('NaN does not loop observers', function() {
el.clearObserverCounts();
el.addEventListener('notifierwithoutcomputing-changed', function(e) {
el.addEventListener('notifierwithoutcomputing-changed', function() {
if (el.observerCounts.notifierWithoutComputingChanged >= 3) {
throw new Error('infinite loop!');
}
@ -155,7 +155,7 @@ suite('single-element binding effects', function() {
test('computed property with multiple dependencies', function() {
var notified = 0;
el.addEventListener('computed-from-multiple-values-changed', function(e) {
el.addEventListener('computed-from-multiple-values-changed', function() {
notified++;
});
el.sum1 = 10;
@ -195,7 +195,7 @@ suite('single-element binding effects', function() {
test('no read-only notification sent with assignment', function() {
var notified = 0;
el.addEventListener('readonlyvalue-changed', function(e) {
el.addEventListener('readonlyvalue-changed', function() {
notified++;
});
el.readonlyvalue = 47;
@ -663,7 +663,7 @@ suite('avoid non-bubbling event gotchas', function() {
suite('warnings', function() {
var el;
var warn;
var warn; //eslint-disable-line no-unused-vars
setup(function() {
el = document.createElement('x-basic');
@ -859,6 +859,32 @@ suite('compound binding / string interpolation', function() {
});
suite('order of effects', function() {
var el;
setup(function() {
el = document.createElement('x-order-of-effects-grand-parent').$.child;
});
test('effects are sorted', function() {
assert.equal(el.invocations.length, 0);
el.base = 'changed';
var expected = [
'compute',
'annotation', // as observed by child
'annotatedComputation', // as observed by child
'reflect',
'notify', // as observed by grand-parent
'observer',
'complexObserver'
];
assert.deepEqual(el.invocations, expected);
});
});
</script>
</body>

View File

@ -172,7 +172,7 @@
value: 5
},
attrValue: {
value: 'attrValue',
value: 'attrValue'
},
attrNumber: {
value: '42'
@ -181,4 +181,4 @@
});
</script>
</dom-module>
</dom-module>

View File

@ -1,182 +1,183 @@
<!doctype html>
<!--
@license
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
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
-->
<html>
<head>
<meta charset="utf-8">
<script src="../../../webcomponentsjs/webcomponents-lite.js"></script>
<script src="../../../web-component-tester/browser.js"></script>
<title>css-parse</title>
<link rel="import" href="../../polymer.html">
</head>
<body>
<style id="test">
:host {
background: red;
}
.foo .bar .baz, zonk[happy]:focus {
font-family: sans-serif;
font-size: 15px;
}
@-webkit-keyframes fill-unfill-rotate {
12.5% { transform: rotate(135deg); }
25% { transform: rotate(270deg); }
37.5% { transform: rotate(405deg); }
50% { transform: rotate(540deg); }
62.5% { transform: rotate(675deg); }
75% { transform: rotate(810deg); }
87.5% { transform: rotate(945deg); }
to { transform: rotate(1080deg); }
}
@media (max-width: 400px) {
div {
margin-left: 0 !important;
}
}
</style>
<style id="test-ignore">
@import '';
/* comment */
.stuff {
background: red;
}
/* comment */
/*
This is a multi-line comment
*/
/*.aclassThatShouldBeIgnored {
someProperty: thatMustNotShowUp
}*/
</style>
<style id="short-escape-sequence">
.\33 d-model {
border-top: 3px solid red;
}
.\a33 d-model {
border-top: 3px solid red;
}
.\b333 d-model {
border-top: 3px solid red;
}
.\c3333 d-model {
border-top: 3px solid red;
}
.\d33333 d-model {
border-top: 3px solid red;
}
.\e33333d-model {
border-top: 3px solid red;
}
</style>
<style id="multiple-spaces">
.foo .bar {}
.foo .bar {}
.foo
.bar {}
</style>
<script>
function sanitizeCss(text) {
return text.replace(/[\s]+/g, ' ').trim();
}
suite('css-parse', function() {
setup(function() {
css = Polymer.CssParse;
s = document.querySelector('style#test');
tree = css.parse(s.textContent);
});
test('css rules parse', function() {
assert.equal(tree.rules.length, 4, 'unexpected number of rules');
assert.equal(tree.rules[2].rules.length, 8, 'unexpected number of rules in keyframes');
assert.equal(tree.rules[3].rules.length, 1, 'unexpected number of rules in @media');
});
test('rule selectors parse', function() {
assert.equal(tree.rules[0].selector, ':host', 'unexpected selector');
assert.equal(tree.rules[2].selector, '@-webkit-keyframes fill-unfill-rotate', 'unexpected selector in keyframes');
assert.equal(tree.rules[3].selector, '@media (max-width: 400px)', 'unexpected selector in @media');
});
test('rule cssText parse', function() {
assert.equal(tree.rules[0].cssText, 'background: red;', 'unexpected cssText');
assert.match(tree.rules[2].cssText, /^12.5%/, 'unexpected cssText in keyframes');
assert.equal(tree.rules[2].rules[2].cssText, 'transform: rotate(405deg);', 'unexpected cssText in keyframes');
assert.match(tree.rules[3].cssText, /^div/, 'unexpected cssText in @media');
assert.equal(tree.rules[3].rules[0].cssText, 'margin-left: 0 !important;', 'unexpected cssText in @media');
});
test('rule types', function() {
assert.equal(tree.rules[0].type, css.types.STYLE_RULE);
assert.equal(tree.rules[1].type, css.types.STYLE_RULE);
assert.equal(tree.rules[2].type, css.types.KEYFRAMES_RULE);
assert.equal(tree.rules[3].type, css.types.MEDIA_RULE);
assert.equal(tree.rules[3].rules[0].type, css.types.STYLE_RULE);
});
test('rules stringify', function() {
var orig = sanitizeCss(s.textContent);
var result = sanitizeCss(css.stringify(tree));
assert.equal(result, orig, 'unexpected stringified output');
});
test('parse correctly ignores @import and comments', function() {
var s2 = document.querySelector('#test-ignore');
var t = css.parse(s2.textContent);
assert.equal(t.rules[0].selector, '.stuff', 'unexpected rule selector');
assert.equal(t.rules[0].cssText, 'background: red;', 'unexpected rule cssText');
var result = sanitizeCss(css.stringify(t));
assert.equal(result, '.stuff { background: red; }', 'unexpected stringified output');
});
test('short escape sequences', function() {
var s3 = document.querySelector('#short-escape-sequence');
var t = css.parse(s3.textContent);
assert.equal(t.rules[0].selector, '.\\000033d-model');
assert.equal(t.rules[1].selector, '.\\000a33d-model');
assert.equal(t.rules[2].selector, '.\\00b333d-model');
assert.equal(t.rules[3].selector, '.\\0c3333d-model');
assert.equal(t.rules[4].selector, '.\\d33333d-model');
assert.equal(t.rules[5].selector, '.\\e33333d-model');
});
test('multiple consequent spaces in CSS selector', function() {
var s4 = document.querySelector('#multiple-spaces');
var t = css.parse(s4.textContent);
assert.equal(t.rules[0].selector, '.foo .bar');
assert.equal(t.rules[1].selector, '.foo .bar');
assert.equal(t.rules[2].selector, '.foo .bar');
});
});
</script>
</body>
</html>
<!doctype html>
<!--
@license
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
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
-->
<html>
<head>
<meta charset="utf-8">
<script src="../../../webcomponentsjs/webcomponents-lite.js"></script>
<script src="../../../web-component-tester/browser.js"></script>
<title>css-parse</title>
<link rel="import" href="../../polymer.html">
</head>
<body>
<style id="test">
:host {
background: red;
}
.foo .bar .baz, zonk[happy]:focus {
font-family: sans-serif;
font-size: 15px;
}
@-webkit-keyframes fill-unfill-rotate {
12.5% { transform: rotate(135deg); }
25% { transform: rotate(270deg); }
37.5% { transform: rotate(405deg); }
50% { transform: rotate(540deg); }
62.5% { transform: rotate(675deg); }
75% { transform: rotate(810deg); }
87.5% { transform: rotate(945deg); }
to { transform: rotate(1080deg); }
}
@media (max-width: 400px) {
div {
margin-left: 0 !important;
}
}
</style>
<style id="test-ignore">
@import '';
/* comment */
.stuff {
background: red;
}
/* comment */
/*
This is a multi-line comment
*/
/*.aclassThatShouldBeIgnored {
someProperty: thatMustNotShowUp
}*/
</style>
<style id="short-escape-sequence">
.\33 d-model {
border-top: 3px solid red;
}
.\a33 d-model {
border-top: 3px solid red;
}
.\b333 d-model {
border-top: 3px solid red;
}
.\c3333 d-model {
border-top: 3px solid red;
}
.\d33333 d-model {
border-top: 3px solid red;
}
.\e33333d-model {
border-top: 3px solid red;
}
</style>
<style id="multiple-spaces">
.foo .bar {}
.foo .bar {}
.foo
.bar {}
</style>
<script>
function sanitizeCss(text) {
return text.replace(/[\s]+/g, ' ').trim();
}
suite('css-parse', function() {
var css, s, tree;
setup(function() {
css = Polymer.CssParse;
s = document.querySelector('style#test');
tree = css.parse(s.textContent);
});
test('css rules parse', function() {
assert.equal(tree.rules.length, 4, 'unexpected number of rules');
assert.equal(tree.rules[2].rules.length, 8, 'unexpected number of rules in keyframes');
assert.equal(tree.rules[3].rules.length, 1, 'unexpected number of rules in @media');
});
test('rule selectors parse', function() {
assert.equal(tree.rules[0].selector, ':host', 'unexpected selector');
assert.equal(tree.rules[2].selector, '@-webkit-keyframes fill-unfill-rotate', 'unexpected selector in keyframes');
assert.equal(tree.rules[3].selector, '@media (max-width: 400px)', 'unexpected selector in @media');
});
test('rule cssText parse', function() {
assert.equal(tree.rules[0].cssText, 'background: red;', 'unexpected cssText');
assert.match(tree.rules[2].cssText, /^12.5%/, 'unexpected cssText in keyframes');
assert.equal(tree.rules[2].rules[2].cssText, 'transform: rotate(405deg);', 'unexpected cssText in keyframes');
assert.match(tree.rules[3].cssText, /^div/, 'unexpected cssText in @media');
assert.equal(tree.rules[3].rules[0].cssText, 'margin-left: 0 !important;', 'unexpected cssText in @media');
});
test('rule types', function() {
assert.equal(tree.rules[0].type, css.types.STYLE_RULE);
assert.equal(tree.rules[1].type, css.types.STYLE_RULE);
assert.equal(tree.rules[2].type, css.types.KEYFRAMES_RULE);
assert.equal(tree.rules[3].type, css.types.MEDIA_RULE);
assert.equal(tree.rules[3].rules[0].type, css.types.STYLE_RULE);
});
test('rules stringify', function() {
var orig = sanitizeCss(s.textContent);
var result = sanitizeCss(css.stringify(tree));
assert.equal(result, orig, 'unexpected stringified output');
});
test('parse correctly ignores @import and comments', function() {
var s2 = document.querySelector('#test-ignore');
var t = css.parse(s2.textContent);
assert.equal(t.rules[0].selector, '.stuff', 'unexpected rule selector');
assert.equal(t.rules[0].cssText, 'background: red;', 'unexpected rule cssText');
var result = sanitizeCss(css.stringify(t));
assert.equal(result, '.stuff { background: red; }', 'unexpected stringified output');
});
test('short escape sequences', function() {
var s3 = document.querySelector('#short-escape-sequence');
var t = css.parse(s3.textContent);
assert.equal(t.rules[0].selector, '.\\000033d-model');
assert.equal(t.rules[1].selector, '.\\000a33d-model');
assert.equal(t.rules[2].selector, '.\\00b333d-model');
assert.equal(t.rules[3].selector, '.\\0c3333d-model');
assert.equal(t.rules[4].selector, '.\\d33333d-model');
assert.equal(t.rules[5].selector, '.\\e33333d-model');
});
test('multiple consequent spaces in CSS selector', function() {
var s4 = document.querySelector('#multiple-spaces');
var t = css.parse(s4.textContent);
assert.equal(t.rules[0].selector, '.foo .bar');
assert.equal(t.rules[1].selector, '.foo .bar');
assert.equal(t.rules[2].selector, '.foo .bar');
});
});
</script>
</body>
</html>

View File

@ -15,19 +15,20 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
<script src="../../../web-component-tester/browser.js"></script>
<link rel="import" href="../../polymer.html">
<link rel="import" href="custom-style-late-import.html">
</head>
<body>
<input id="input" is="x-input">
<script>
/* global input */
suite('custom-style late property definition', function() {
test('late defined properties applied to custom-style', function() {
assertComputed(input, '8px');
});
});
function assertComputed(element, value, property, pseudo) {

View File

@ -21,6 +21,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
</template>
<script>
/* global earlyDomBind earlyBoundChild decEl1 decEl2 decDomBind z container needsHost*/
earlyDomBind.value = 'hi!';
</script>
@ -182,7 +183,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
assert.equal(el.$.local.textContent, 'hey', 'dom-bind did not distribute');
document.body.removeChild(el);
done();
})
});
});
test('dom-bind distributed when inserted in element attached (flush)', function() {

View File

@ -111,7 +111,7 @@
value: true
},
prop: {
value: 'outer',
value: 'outer'
},
item: {
value: function() { return {prop: 'outerItem'}; }
@ -141,13 +141,13 @@
is: 'x-nested-if-individual',
properties: {
prop1: {
value: 'prop1',
value: 'prop1'
},
prop2: {
value: 'prop2',
value: 'prop2'
},
prop3: {
value: 'prop3',
value: 'prop3'
},
item: {
value: function() { return {prop: 'outerItem'}; }

View File

@ -72,7 +72,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
</div>
<script>
/* global configured individual unconfigured1 unconfigured2 inDocumentContainer inDocumentIf structuredContainer structuredDomIf structuredDomBind outerContainer innerContainer shouldBeRemoved toBeRemoved removalContainer*/
suite('nested pre-configured dom-if', function() {
test('parent scope binding', function() {

View File

@ -12,7 +12,7 @@
</template>
</dom-module>
<script>
TestElement = Polymer({
window.TestElement = Polymer({
is: 'Test-element'
});
</script>
</script>

View File

@ -52,9 +52,9 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
});
test('mixed case element creation', function() {
t = new TestElement();
var t = new TestElement(); //eslint-disable-line
assert.ok(t.$.content);
})
});
});

View File

@ -26,7 +26,7 @@ window.data = [
{ prop: 'prop-1-3-2' },
{ prop: 'prop-1-3-3' }
]
},
}
]
},
{
@ -55,7 +55,7 @@ window.data = [
{ prop: 'prop-2-3-2' },
{ prop: 'prop-2-3-3' }
]
},
}
]
},
{
@ -84,7 +84,7 @@ window.data = [
{ prop: 'prop-3-3-2' },
{ prop: 'prop-3-3-3' }
]
},
}
]
}
];
@ -129,19 +129,19 @@ window.data = [
notify: true
},
inneraProp: {
notify: true,
notify: true
},
itemaProp: {
notify: true
},
innerbProp: {
notify: true,
notify: true
},
itembProp: {
notify: true
},
innercProp: {
notify: true,
notify: true
},
itemcProp: {
notify: true
@ -167,19 +167,19 @@ window.data = [
notify: true
},
inneraProp: {
notify: true,
notify: true
},
itemaProp: {
notify: true
},
innerbProp: {
notify: true,
notify: true
},
itembProp: {
notify: true
},
innercProp: {
notify: true,
notify: true
},
itemcProp: {
notify: true
@ -310,7 +310,7 @@ window.data = [
value: window.data
},
prop: {
value: 'outer',
value: 'outer'
},
item: {
value: function() { return {prop: 'outerItem'}; }
@ -467,7 +467,7 @@ window.data = [
created: function() {
var time = performance.now();
time += 4;
while (performance.now() < time) {}
while (performance.now() < time) {} //eslint-disable-line no-empty
}
});
</script>

View File

@ -81,6 +81,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
</div>
<script>
/* global unconfigured1 unconfigured primitive limited inDocumentRepeater configured inDocumentContainer inDocumentContainerOrig unconfigured2 primitiveLarge simple:true model:true stamped:true chunked */
/*
Expected:
@ -105,9 +106,9 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
test('items must be array', function() {
var warned = false;
inDocumentRepeater._error = function(message) {
assert.match(message, /expected array/)
assert.match(message, /expected array/);
warned = true;
}
};
inDocumentRepeater.items = {};
assert.equal(warned, true, 'should warn when items is not array');
});
@ -648,7 +649,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
test('parent scope binding', function() {
var stamped = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)');
unconfigured1.prop = 'outer';
unconfigured1.item = {prop: 'outerItem'}
unconfigured1.item = {prop: 'outerItem'};
assert.equal(stamped[0].outerProp, 'outer');
assert.equal(stamped[0].outerItemProp, 'outerItem');
assert.equal(stamped[1].itemaProp, 'prop-1');
@ -3324,7 +3325,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
assert.equal(repeater1.renderedItemCount, 5, 'renderedItemCount is writable');
repeater1.filter = function(item) {
return (item != 'a' && item != 'e');
}
};
repeater1.render();
assert.equal(repeater1.renderedItemCount, 3, 'renderedItemCount incorrect after filter');
// reset repeater

View File

@ -73,7 +73,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
down: 'handler',
up: 'handler'
},
handler: function(e, detail) {
handler: function() {
}
});
</script>

View File

@ -81,11 +81,11 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
assert.equal(obj.mousedown.downup, 2, 'mousedown downup');
assert.equal(obj.mousedown.track, 1, 'mousedown track');
assert.equal(obj.mousedown.tap, 1, 'mousedown tap');
assert.equal(obj.mousedown._count, 4, 'total mousedown')
assert.equal(obj.mousedown._count, 4, 'total mousedown');
assert.equal(obj.touchstart.downup, 2, 'touchstart downup');
assert.equal(obj.touchstart.tap, 1, 'touchstart tap');
assert.equal(obj.touchstart.track, 1, 'touchstart track');
assert.equal(obj.touchstart._count, 4, 'total touchstart')
assert.equal(obj.touchstart._count, 4, 'total touchstart');
assert.equal(obj.touchmove.track, 1, 'touchmove track');
assert.equal(obj.touchmove._count, 1, 'total touchmove');
assert.equal(obj.touchend.downup, 2, 'touchend downup');
@ -100,17 +100,17 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
assert.equal(obj.mousedown.downup, 2, 'mousedown downup');
assert.equal(obj.mousedown.track, 1, 'mousedown track');
assert.equal(obj.mousedown.tap, 1, 'mousedown tap');
assert.equal(obj.mousedown._count, 4, 'total mousedown')
assert.equal(obj.mousedown._count, 4, 'total mousedown');
assert.equal(obj.touchstart.downup, 2, 'touchstart downup');
assert.equal(obj.touchstart.tap, 1, 'touchstart tap');
assert.equal(obj.touchstart.track, 1, 'touchstart track');
assert.equal(obj.touchstart._count, 4, 'total touchstart')
assert.equal(obj.touchstart._count, 4, 'total touchstart');
assert.equal(obj.touchmove.track, 1, 'touchmove track');
assert.equal(obj.touchmove._count, 1, 'total touchmove');
assert.equal(obj.touchend.downup, 2, 'touchend downup');
assert.equal(obj.touchend.track, 1, 'touchend track');
assert.equal(obj.touchend.tap, 1, 'touchend tap');
assert.equal(obj.touchend._count, 4, 'total touchend');;
assert.equal(obj.touchend._count, 4, 'total touchend');
});
test('dynamic', function() {
@ -142,7 +142,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
assert.equal(obj.touchstart.downup, 0, 'touchstart downup');
assert.equal(obj.touchstart._count, 0, 'total touchstart');
assert.equal(obj.touchmove.track, 0, 'touchmove track');
assert.equal(obj.touchmove._count, 0, 'total touchmove')
assert.equal(obj.touchmove._count, 0, 'total touchmove');
assert.equal(obj.touchstart.tap, 0, 'touchstart tap');
assert.equal(obj.touchend.downup, 0, 'touchend downup');
assert.equal(obj.touchend.track, 0, 'touchend track');
@ -164,7 +164,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
assert.equal(obj.touchstart.downup, 0, 'touchstart downup');
assert.equal(obj.touchstart._count, 0, 'total touchstart');
assert.equal(obj.touchmove.track, 0, 'touchmove track');
assert.equal(obj.touchmove._count, 0, 'total touchmove')
assert.equal(obj.touchmove._count, 0, 'total touchmove');
assert.equal(obj.touchstart.tap, 0, 'touchstart tap');
assert.equal(obj.touchend.downup, 0, 'touchend downup');
assert.equal(obj.touchend.track, 0, 'touchend track');
@ -202,7 +202,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
test('target finding returns null outside the window', function() {
var actual = Polymer.Gestures.deepTargetFind(-1, -1);
assert.equal(actual, null);
})
});
test('find the div in document', function() {
var x = divLocation.left, y = divLocation.top;

View File

@ -14,6 +14,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
<script src="../../../web-component-tester/browser.js"></script>
<script src="../../../webcomponentsjs/webcomponents-lite.js"></script>
<script>
/* global origOwnProps:true */
window.origOwnProps = Object.getOwnPropertyNames(window).reduce(function(props, prop) {
return props[prop] = true && props;
}, {});

View File

@ -27,7 +27,7 @@
},
observers: [
'objSubpathChanged(obj.*)',
'objValueChanged(obj.value)',
'objValueChanged(obj.value)'
],
created: function() {
this.observerCounts = {
@ -51,7 +51,7 @@
objValueChanged: function(value) {
this.observerCounts.objValueChanged++;
assert.equal(this.obj.value, value);
},
}
});
</script>
</dom-module>
@ -71,7 +71,7 @@
},
observers: [
'objSubpathChanged(obj.*)',
'objValueChanged(obj.value)',
'objValueChanged(obj.value)'
],
created: function() {
this.observerCounts = {
@ -96,7 +96,7 @@
objValueChanged: function(value) {
this.observerCounts.objValueChanged++;
assert.equal(this.obj.value, value);
},
}
});
</script>
</dom-module>
@ -211,7 +211,7 @@
'arrayChanged keySplices incorrect');
}
},
arrayChangedDeep: function(info) { },
arrayChangedDeep: function() { },
arrayNoCollChanged: function(splices) {
this.observerCounts.arrayNoCollChanged++;
if (this.arrayNoColl.length) {
@ -221,7 +221,7 @@
'arrayNoCollChanged indexSplices incorrect');
}
},
arrayOrPropChanged: function(prop, splices) {
arrayOrPropChanged: function(prop) {
this.observerCounts.arrayOrPropChanged++;
assert.equal(prop, this.prop);
},

View File

@ -813,7 +813,7 @@ suite('path API', function() {
el.arrayChanged = nop;
el.array = ['orig1', 'orig2', 'orig3'];
Polymer.Collection.get(el.array);
el.arrayChanged = function(change) {
el.arrayChanged = function() {
throw new Error("should not notify");
};
var ret = el.push('array');
@ -828,7 +828,7 @@ suite('path API', function() {
el.arrayChanged = nop;
el.array = [];
Polymer.Collection.get(el.array);
el.arrayChanged = function(change) {
el.arrayChanged = function() {
throw new Error("should not notify");
};
var ret = el.pop('array');
@ -840,8 +840,7 @@ suite('path API', function() {
el.arrayChanged = nop;
el.array = ['orig1', 'orig2', 'orig3'];
Polymer.Collection.get(el.array);
var key = el.array.length;
el.arrayChanged = function(change) {
el.arrayChanged = function() {
throw new Error("should not notify");
};
var ret = el.unshift('array');
@ -856,7 +855,7 @@ suite('path API', function() {
el.arrayChanged = nop;
el.array = [];
Polymer.Collection.get(el.array);
el.arrayChanged = function(change) {
el.arrayChanged = function() {
throw new Error("should not notify");
};
var ret = el.shift('array');
@ -868,9 +867,8 @@ suite('path API', function() {
test('corner: no-op splice array', function() {
el.arrayChanged = nop;
el.array = ['orig1', 'orig2', 'orig3'];
var key = el.array.length;
Polymer.Collection.get(el.array);
el.arrayChanged = function(change) {
el.arrayChanged = function() {
throw new Error("should not notify");
};
var ret = el.splice('array');

View File

@ -306,7 +306,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
// NOTE: these tests are mostly for Shady but running them on Shadow DOM
// ensures Polymer.dom functions correctly under Shadow DOM.
usingShady = !Polymer.Settings.useNativeShadow;
})
});
suite('appendChild & removeChild of <content>', function() {
@ -988,6 +988,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
var s1 = document.createElement('span');
var s2 = document.createElement('span');
var s3 = document.createElement('span');
var composedChildren;
frag.appendChild(s1);
frag.appendChild(s2);
frag.appendChild(s3);
@ -1000,7 +1001,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
assert.equal(host.$.distWrapper.children[1], s2);
assert.equal(host.$.distWrapper.children[2], s3);
assert.equal(host.$.distWrapper.children[3], s0);
var composedChildren = Polymer.TreeApi.Composed.getChildNodes(host.$.distWrapper);
composedChildren = Polymer.TreeApi.Composed.getChildNodes(host.$.distWrapper);
assert.equal(composedChildren.length, 4);
assert.equal(composedChildren[0], s1);
assert.equal(composedChildren[1], s2);
@ -1013,7 +1014,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
Polymer.dom.flush();
if (host.shadyRoot) {
assert.equal(host.$.distWrapper.children.length, 1);
var composedChildren = Polymer.TreeApi.Composed.getChildNodes(host.$.distWrapper);
composedChildren = Polymer.TreeApi.Composed.getChildNodes(host.$.distWrapper);
assert.equal(composedChildren.length, 1);
assert.equal(composedChildren[0], s0);
}
@ -1027,6 +1028,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
var s1 = document.createElement('span');
var s2 = document.createElement('span');
var s3 = document.createElement('span');
var composedChildren;
frag.appendChild(s1);
frag.appendChild(s2);
frag.appendChild(s3);
@ -1039,7 +1041,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
assert.equal(host.$.distWrapper.children[1], s2);
assert.equal(host.$.distWrapper.children[2], s3);
assert.equal(host.$.distWrapper.children[3], s0);
var composedChildren = Polymer.TreeApi.Composed.getChildNodes(host.$.distWrapper);
composedChildren = Polymer.TreeApi.Composed.getChildNodes(host.$.distWrapper);
assert.equal(composedChildren.length, 4);
assert.equal(composedChildren[0], s1);
assert.equal(composedChildren[1], s2);
@ -1052,7 +1054,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
Polymer.dom.flush();
if (host.shadyRoot) {
assert.equal(host.$.distWrapper.children.length, 1);
var composedChildren = Polymer.TreeApi.Composed.getChildNodes(host.$.distWrapper);
composedChildren = Polymer.TreeApi.Composed.getChildNodes(host.$.distWrapper);
assert.equal(composedChildren.length, 1);
assert.equal(composedChildren[0], s0);
}
@ -1139,7 +1141,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
test('moving children between distributing host and fragment', function() {
var h1 = document.createElement('x-dist');
var h2 = document.createDocumentFragment();;
var h2 = document.createDocumentFragment();
document.body.appendChild(h1);
Polymer.dom.flush();
var d = document.createElement('div');
@ -1174,7 +1176,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
var div = document.createElement('div');
div.innerHTML = '<x-dist><div></div></x-dist>';
var h1 = div.firstChild;
var h2 = document.createDocumentFragment();;
var h2 = document.createDocumentFragment();
document.body.appendChild(h1);
Polymer.dom.flush();
var d = Polymer.dom(h1).firstElementChild;
@ -1285,7 +1287,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
test('moving children between distributing host with deep insertion and fragment', function() {
var h1 = document.createElement('x-dist-inside-deep-tree');
var h2 = document.createDocumentFragment();;
var h2 = document.createDocumentFragment();
document.body.appendChild(h1);
Polymer.dom.flush();
var d = document.createElement('div');
@ -1320,7 +1322,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
var div = document.createElement('div');
div.innerHTML = '<x-dist-inside-deep-tree><div></div></x-dist-inside-deep-tree>';
var h1 = div.firstChild;
var h2 = document.createDocumentFragment();;
var h2 = document.createDocumentFragment();
document.body.appendChild(h1);
Polymer.dom.flush();
var d = Polymer.dom(h1).firstElementChild;
@ -1352,7 +1354,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
test('moving children between distributing host with shallow insertion and fragment', function() {
var h1 = document.createElement('x-dist-simple');
var h2 = document.createDocumentFragment();;
var h2 = document.createDocumentFragment();
document.body.appendChild(h1);
Polymer.dom.flush();
var d = document.createElement('div');
@ -1730,7 +1732,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
el.$.staticIf.if = true;
Polymer.dom.flush();
assert.ok(Polymer.dom(el.root).querySelector('#static'));
var ip = Polymer.dom(el.root).querySelector('content');
ip = Polymer.dom(el.root).querySelector('content');
assert.ok(ip);
assert.equal(Polymer.dom(ip).getDistributedNodes()[0], c1);
if (el.shadyRoot) {

View File

@ -26,7 +26,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
Polymer({
is:'test-static'
});
});
});
</script>
</dom-module>
@ -143,7 +143,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
Polymer({
is:'test-content-attr3'
});
});
});
</script>
</dom-module>
@ -156,10 +156,10 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
Polymer({
is:'test-content-attr-inside'
});
});
});
</script>
</dom-module>
<test-content><div>A</div><div>B</div></test-content>
@ -256,7 +256,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
var recordedInfo, elAddedInObserver;
var observerCallCount = 0;
var handle = Polymer.dom(el).observeNodes(function(info) {
Polymer.dom(el).observeNodes(function(info) {
if (Polymer.dom(info.target).childNodes.length < 5) {
elAddedInObserver = document.createElement('div');
Polymer.dom(info.target).appendChild(elAddedInObserver);
@ -307,9 +307,9 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
assert.sameMembers(el.getEffectiveChildNodes(), nodes);
Polymer.dom(el).unobserveNodes(handle);
Polymer.dom(el).removeChild(d);
Polymer.dom(el).removeChild(d1);
Polymer.dom(el).removeChild(d1);
setTimeout(function() {
assert.notEqual(nodes.length, el.getEffectiveChildNodes().length)
assert.notEqual(nodes.length, el.getEffectiveChildNodes().length);
document.body.removeChild(el);
done();
});
@ -486,7 +486,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
var el = document.createElement('test-content1');
document.body.appendChild(el);
var recorded;
var handle = Polymer.dom(el.$.content).observeNodes(function(info) {
Polymer.dom(el.$.content).observeNodes(function(info) {
recorded = info;
});
Polymer.dom.flush();
@ -518,7 +518,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
var el = document.createElement('staticDiv');
document.body.appendChild(el);
var recorded;
var handle = Polymer.dom(el).observeNodes(function(info) {
Polymer.dom(el).observeNodes(function(info) {
recorded = info;
});
Polymer.dom.flush();
@ -681,10 +681,10 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
});
});
});
});
});
});
test('observe effective children attr changes inside deep distributing element (async)', function(done) {
var el = document.createElement('test-content-attr3');
document.body.appendChild(el);
@ -710,12 +710,12 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
Polymer.dom(d).setAttribute('c', '');
setTimeout(function() {
assert.equal(recorded.addedNodes.length, 1);
assert.equal(recorded.removedNodes.length, 0);
assert.equal(recorded.removedNodes.length, 0);
assert.equal(recorded.addedNodes[0], d);
Polymer.dom(d).removeAttribute('c');
setTimeout(function() {
assert.equal(recorded.addedNodes.length, 0);
assert.equal(recorded.removedNodes.length, 1);
assert.equal(recorded.removedNodes.length, 1);
assert.equal(recorded.removedNodes[0], d);
recorded = null;
Polymer.dom(content).unobserveNodes(handle);
@ -755,12 +755,12 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
Polymer.dom(d).setAttribute('c', '');
setTimeout(function() {
assert.equal(recorded.addedNodes.length, 1);
assert.equal(recorded.removedNodes.length, 0);
assert.equal(recorded.removedNodes.length, 0);
assert.equal(recorded.addedNodes[0], d);
Polymer.dom(d).removeAttribute('c');
setTimeout(function() {
assert.equal(recorded.addedNodes.length, 0);
assert.equal(recorded.removedNodes.length, 1);
assert.equal(recorded.removedNodes.length, 1);
assert.equal(recorded.removedNodes[0], d);
recorded = null;
Polymer.dom(content).unobserveNodes(handle);
@ -779,15 +779,15 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
var el = document.createElement('test-content1');
document.body.appendChild(el);
var r1 = 0;
var h1 = Polymer.dom(el.$.content).observeNodes(function(info) {
var h1 = Polymer.dom(el.$.content).observeNodes(function() {
r1++;
});
var r2 = 0;
var h2 = Polymer.dom(el.$.content).observeNodes(function(info) {
var h2 = Polymer.dom(el.$.content).observeNodes(function() {
r2++;
});
var r3 = 0;
var h3 = Polymer.dom(el.$.content).observeNodes(function(info) {
var h3 = Polymer.dom(el.$.content).observeNodes(function() {
r3++;
});
// add
@ -798,21 +798,21 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
assert.equal(r2, 1);
assert.equal(r3, 1);
Polymer.dom(el.$.content).unobserveNodes(h1);
var d = document.createElement('div');
d = document.createElement('div');
Polymer.dom(el).appendChild(d);
Polymer.dom.flush();
assert.equal(r1, 1);
assert.equal(r2, 2);
assert.equal(r3, 2);
Polymer.dom(el.$.content).unobserveNodes(h2);
var d = document.createElement('div');
d = document.createElement('div');
Polymer.dom(el).appendChild(d);
Polymer.dom.flush();
assert.equal(r1, 1);
assert.equal(r2, 2);
assert.equal(r3, 3);
Polymer.dom(el.$.content).unobserveNodes(h3);
var d = document.createElement('div');
d = document.createElement('div');
Polymer.dom(el).appendChild(d);
Polymer.dom.flush();
assert.equal(r1, 1);
@ -825,28 +825,28 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
assert.equal(r1, 2);
assert.equal(r2, 3);
assert.equal(r3, 4);
var d = document.createElement('div');
d = document.createElement('div');
Polymer.dom(el).appendChild(d);
Polymer.dom.flush();
assert.equal(r1, 3);
assert.equal(r2, 4);
assert.equal(r3, 5);
Polymer.dom(el.$.content).unobserveNodes(h3);
var d = document.createElement('div');
d = document.createElement('div');
Polymer.dom(el).appendChild(d);
Polymer.dom.flush();
assert.equal(r1, 4);
assert.equal(r2, 5);
assert.equal(r3, 5);
Polymer.dom(el.$.content).unobserveNodes(h2);
var d = document.createElement('div');
d = document.createElement('div');
Polymer.dom(el).appendChild(d);
Polymer.dom.flush();
assert.equal(r1, 5);
assert.equal(r2, 5);
assert.equal(r3, 5);
Polymer.dom(el.$.content).unobserveNodes(h1);
var d = document.createElement('div');
d = document.createElement('div');
Polymer.dom(el).appendChild(d);
Polymer.dom.flush();
assert.equal(r1, 5);

View File

@ -1,19 +1,21 @@
<script>
/* global chai */
var assert = chai.assert;
var configureList = [];
var readyList = [];
function clearTestLists() {
function clearTestLists() { //eslint-disable-line
configureList = [];
readyList = [];
}
var readyBehavior = {
moniker: function() {
return this.is + (this.id ? '#' + this.id : '')
return this.is + (this.id ? '#' + this.id : '');
},
// use private, stateful, method for testing purposes
_configure: function() {
chai.assert.isTrue(!this.isAttached, 'Element should not be attached when configured.');
assert.isTrue(!this.isAttached, 'Element should not be attached when configured.');
configureList.push(this.moniker());
},
ready: function() {
@ -21,7 +23,7 @@
},
attached: function() {
chai.assert.isTrue(this._readied, 'Element not ready when attached');
assert.isTrue(this._readied, 'Element not ready when attached');
}
};
</script>

View File

@ -1,4 +1,5 @@
suite('ready', function() {
/* globals configureList readyList clearTestLists */
var configure = ['x-ready', 'x-zot#a', 'x-zot#b', 'x-zot#c', 'x-zot#d', 'x-foo#foo', 'x-bar#bar1', 'x-zot', 'x-bar#bar2', 'x-zot'];
var ready = ['x-zot#a', 'x-zot#b', 'x-zot#c', 'x-zot#d', 'x-zot', 'x-bar#bar1', 'x-zot', 'x-bar#bar2', 'x-foo#foo', 'x-ready'];

View File

@ -116,14 +116,14 @@ test('Reproject', function() {
var b = p.firstChild;
var content = p.lastChild;
syncLightDOM(p);
setRootInnerHTML(p.shadyRoot,
'a: <content select=a></content>b: <content select=b></content>');
var textNodeA = p.shadyRoot.firstChild;
var contentA = p.shadyRoot.childNodes[1];
var textNodeB = p.shadyRoot.childNodes[2]
var textNodeB = p.shadyRoot.childNodes[2];
var contentB = p.shadyRoot.childNodes[3];
function testRender() {
@ -252,7 +252,7 @@ suite('Mutate light DOM', function() {
test('removeChild - mutate shadow', function() {
var host = document.createElement('x-content-test');
setInnerHTML(host, '<a>Hello</a>');
syncLightDOM(host);
@ -360,7 +360,6 @@ suite('Mutate light DOM', function() {
test('replaceChild - mutate host', function() {
var host = document.createElement('x-content-test');
setInnerHTML(host, '<a>Hello</a>');
var a = host.firstChild;
syncLightDOM(host);
setRootInnerHTML(host.shadyRoot, '<content></content>');
@ -408,7 +407,7 @@ suite('Mutate light DOM', function() {
// NOTE: needed only for this imperative test that needs
// to simulate distribution from `shadyRoot`
child._distributeContent();
assert.deepEqual(Polymer.dom(host.root).querySelectorAll('span#main'), [hostLocalMain]);
assert.deepEqual(Polymer.dom(host.root).querySelectorAll('div#sub'), [childLightSub]);
assert.deepEqual(Polymer.dom(child.root).querySelectorAll('span#sub'), [childLocalSub]);
@ -460,7 +459,7 @@ function setInnerHTML(node, value) {
var temp = node.ownerDocument.createElement('div');
temp.innerHTML = value;
var firstChild;
while (firstChild = temp.firstChild) {
while ((firstChild = temp.firstChild)) {
nativeAppendChild.call(node, firstChild);
}
}

View File

@ -1,121 +1,122 @@
<!doctype html>
<!--
@license
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
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
-->
<html>
<head>
<meta charset="utf-8">
<script src="../../../webcomponentsjs/webcomponents.js"></script>
<script src="../../../web-component-tester/browser.js"></script>
<script>
Polymer = {dom: 'shadow'};
</script>
<link rel="import" href="../../polymer.html">
</head>
<body>
<style is="custom-style">
unknown-host {
display: block;
}
:root {
--border: 2px solid steelblue;
}
</style>
<script>
HTMLImports.whenReady(function() {
// define unknown-host
var proto = Object.create(HTMLElement.prototype);
proto.createdCallback = function() {
this.root = this.createShadowRoot();
}
document.registerElement('unknown-host', {prototype: proto});
});
</script>
<dom-module id="x-foo">
<style>
:host {
border: var(--border);
display: block;
}
</style>
<template>
x-foo
</template>
<script>
HTMLImports.whenReady(function() {
Polymer({
is: 'x-foo'
});
});
</script>
</dom-module>
<dom-module id="x-nest">
<style>
:host {
--border: 4px solid tomato;
}
</style>
<template>
<unknown-host id="unknown"></unknown-host>
</template>
<script>
HTMLImports.whenReady(function() {
Polymer({
is: 'x-nest',
attached: function() {
this.$.unknown.root.appendChild(document.createElement('x-foo'));
}
});
});
</script>
</dom-module>
<script>
suite('scoped-styling-unknown-host', function() {
function assertComputed(element, value, pseudo) {
var computed = getComputedStyle(element, pseudo);
assert.equal(computed['border-top-width'], value, 'computed style incorrect');
}
function assertStylePropertyValue(properties, name, includeValue) {
assert.property(properties, name);
assert.include(properties[name], includeValue);
}
test('element in top level unknown host styled via property defaults', function() {
var host = document.createElement('unknown-host');
var foo = document.createElement('x-foo');
host.root.appendChild(foo);
document.body.appendChild(host);
CustomElements.takeRecords();
assertComputed(foo, '2px');
});
test('element in unknown host styled via containing polymer element', function() {
var n = document.createElement('x-nest');
document.body.appendChild(n);
CustomElements.takeRecords();
var foo = Polymer.dom(n.$.unknown.root).querySelector('x-foo');
assertComputed(foo, '4px');
});
});
</script>
</body>
<!doctype html>
<!--
@license
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
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
-->
<html>
<head>
<meta charset="utf-8">
<script src="../../../webcomponentsjs/webcomponents.js"></script>
<script src="../../../web-component-tester/browser.js"></script>
<script>
Polymer = {dom: 'shadow'};
</script>
<link rel="import" href="../../polymer.html">
</head>
<body>
<style is="custom-style">
unknown-host {
display: block;
}
:root {
--border: 2px solid steelblue;
}
</style>
<script>
HTMLImports.whenReady(function() {
// define unknown-host
var proto = Object.create(HTMLElement.prototype);
proto.createdCallback = function() {
this.root = this.createShadowRoot();
};
document.registerElement('unknown-host', {prototype: proto});
});
</script>
<dom-module id="x-foo">
<style>
:host {
border: var(--border);
display: block;
}
</style>
<template>
x-foo
</template>
<script>
HTMLImports.whenReady(function() {
Polymer({
is: 'x-foo'
});
});
</script>
</dom-module>
<dom-module id="x-nest">
<style>
:host {
--border: 4px solid tomato;
}
</style>
<template>
<unknown-host id="unknown"></unknown-host>
</template>
<script>
HTMLImports.whenReady(function() {
Polymer({
is: 'x-nest',
attached: function() {
this.$.unknown.root.appendChild(document.createElement('x-foo'));
}
});
});
</script>
</dom-module>
<script>
suite('scoped-styling-unknown-host', function() {
function assertComputed(element, value, pseudo) {
var computed = getComputedStyle(element, pseudo);
assert.equal(computed['border-top-width'], value, 'computed style incorrect');
}
/* eslint-disable no-unused-vars */
function assertStylePropertyValue(properties, name, includeValue) {
assert.property(properties, name);
assert.include(properties[name], includeValue);
}
/* eslint-enable no-unused-vars */
test('element in top level unknown host styled via property defaults', function() {
var host = document.createElement('unknown-host');
var foo = document.createElement('x-foo');
host.root.appendChild(foo);
document.body.appendChild(host);
CustomElements.takeRecords();
assertComputed(foo, '2px');
});
test('element in unknown host styled via containing polymer element', function() {
var n = document.createElement('x-nest');
document.body.appendChild(n);
CustomElements.takeRecords();
var foo = Polymer.dom(n.$.unknown.root).querySelector('x-foo');
assertComputed(foo, '4px');
});
});
</script>
</body>

View File

@ -450,6 +450,10 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
}
#endTerm {border: var(--end-term)}
#parenthesis {
background-image: var(--foo-background-image, url(http://placehold.it/400x300));
}
</style>
<div id="me">x-scope</div>
<x-keyframes id="keyframes"></x-keyframes>
@ -478,6 +482,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
<x-dynamic id="dynamic"></x-dynamic>
<div id="wsTerm">new line var</div>
<div id="endTerm">end var</div>
<div id="parenthesis">parenthesis</div>
</template>
<script>
HTMLImports.whenReady(function() {
@ -597,8 +602,8 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
<script>
suite('scoped-styling-var', function() {
function assertComputed(element, value, pseudo) {
var name = 'border-top-width';
function assertComputed(element, value, pseudo, name) {
var name = name || 'border-top-width';
var computed = element.getComputedStyleValue && !pseudo ?
element.getComputedStyleValue(name) :
getComputedStyle(element, pseudo)[name];
@ -835,6 +840,11 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
assertComputed(styled.$.endTerm, '19px');
});
test('variable with parenthesis', function() {
var url = getComputedStyle(styled.$.parenthesis).backgroundImage.replace(/['"]/g, '');
assert.equal('url(http://placehold.it/400x300)', url);
});
// skip for now, until #3326 is fixed
test('custom style class overrides css variable', function() {
var d = document.createElement('x-variable-override');

View File

@ -533,3 +533,12 @@
Polymer({is: 'x-attr-selector'});
</script>
</dom-module>
<script>
Polymer({
is: 'x-scope-no-class',
ready: function() {
this.scopeSubtree(this, true);
}
});
</script>

View File

@ -51,6 +51,10 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
</div>
<x-overriding></x-overriding>
<x-scope-no-class>
<div></div>
</x-scope-no-class>
<script>
suite('scoped-styling', function() {
@ -329,6 +333,10 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
assertComputed(root.querySelector('.blue'), '3px');
});
test('x-scope with no class attribute', function () {
assert.equal(document.querySelector('x-scope-no-class > div').className, 'style-scope x-scope-no-class');
});
});
test('svg classes are dynamically scoped correctly', function() {

View File

@ -21,6 +21,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
<script>
suite('templatizer client and template separate', function() {
/* global childA childB */
var host;

View File

@ -58,7 +58,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
var elt1 = document.querySelector('#elt1');
var elt2 = document.querySelector('#elt2');
var elt3 = document.querySelector('#elt3');
var elt4 = document.querySelector('#elt4');
var elt7 = document.querySelector('#elt7');
test('getContentChildNodes (empty)', function() {
var nodes = elt1.getContentChildNodes();