Skip to content

Commit

Permalink
Merge branch 'master' into 2.0-binding-api-refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinpschaaf committed Apr 13, 2017
2 parents b9fafb7 + afa843c commit cd321a3
Show file tree
Hide file tree
Showing 10 changed files with 101 additions and 10 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "polymer",
"version": "2.0.0-rc.3",
"version": "2.0.0-rc.4",
"main": [
"polymer.html"
],
Expand Down
1 change: 1 addition & 0 deletions lib/elements/dom-bind.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

<link rel="import" href="../utils/boot.html">
<link rel="import" href="../mixins/property-effects.html">
<link rel="import" href="../mixins/mutable-data.html">

<script>

Expand Down
2 changes: 1 addition & 1 deletion lib/mixins/element-mixin.html
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@
* @override
*/
connectedCallback() {
if (window.ShadyCSS) {
if (window.ShadyCSS && this._template) {
window.ShadyCSS.styleElement(this);
}
if (!this.__dataInitialized) {
Expand Down
3 changes: 3 additions & 0 deletions lib/utils/debounce.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@
}
}

/**
* @memberof Polymer
*/
Polymer.Debouncer = Debouncer;
})();
</script>
5 changes: 5 additions & 0 deletions lib/utils/gestures.html
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,12 @@
// if there is not a shadowroot, exit the loop
while (next && next.shadowRoot && !window.ShadyDOM) {
// if there is a node at x/y in the shadowroot, look deeper
let oldNext = next;
next = next.shadowRoot.elementFromPoint(x, y);
// on Safari, elementFromPoint may return the shadowRoot host
if (oldNext === next) {
break;
}
if (next) {
node = next;
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@polymer/polymer",
"version": "2.0.0-rc.3",
"version": "2.0.0-rc.4",
"description": "The Polymer library makes it easy to create your own web components. Give your element some markup and properties, and then use it on a site. Polymer provides features like dynamic templates and data binding to reduce the amount of boilerplate you need to write",
"main": "polymer.html",
"directories": {
Expand Down
1 change: 1 addition & 0 deletions test/runner.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
'unit/styling-cross-scope-var.html',
'unit/styling-cross-scope-apply.html',
'unit/styling-cross-scope-unknown-host.html',
'unit/styling-only-with-template.html',
'unit/custom-style.html',
'unit/custom-style-late.html',
'unit/custom-style-async.html',
Expand Down
8 changes: 8 additions & 0 deletions test/unit/styling-cross-scope-var.html
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,9 @@
suite('scoped-styling-var', function() {

function assertComputed(element, value, pseudo, name) {
// force a style-recalc for Safari missing updated CSS Custom Properties
// https://bugs.webkit.org/show_bug.cgi?id=170708
element.offsetWidth;
name = name || 'border-top-width';
var computed = element.getComputedStyleValue && !pseudo ?
element.getComputedStyleValue(name) :
Expand Down Expand Up @@ -787,6 +790,11 @@
});

test('instances of scoped @keyframes', function(done) {
if (navigator.userAgent.match(/Safari\/603/) && ShadyCSS.nativeCss && ShadyCSS.nativeShadow) {
// `:nth-of-type` is broken in shadow roots on Safari 10.1
// https://bugs.webkit.org/show_bug.cgi?id=166748
this.skip();
}
var xKeyframes = styled.$.keyframes2;
var onAnimationEnd = function() {
assertStylePropertyValue(xKeyframes, 'left', '5px');
Expand Down
79 changes: 79 additions & 0 deletions test/unit/styling-only-with-template.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<!doctype html>
<!--
@license
Copyright (c) 2017 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>
<link rel="import" href="../../polymer.html">
</head>

<body>
<custom-style>
<style is="custom-style">
html {
--mixin: {
border: 2px solid rgb(255, 0, 0);
};
}
</style>
</custom-style>

<custom-style>
<style is="custom-style">
#target {
@apply --mixin;
}
</style>
</custom-style>

<div id="target"></div>
<dom-if><template></template></dom-if>
<dom-repeat><template></template></dom-repeat>

<script>
addEventListener('WebComponentsReady', () => {
class XFoo extends Polymer.Element {
connectedCallback() {
this.spy = sinon.spy(window.ShadyCSS, 'styleElement');
super.connectedCallback();
this.spy.restore();
}
}
customElements.define('x-foo', XFoo);
})
</script>

<script>
suite('styling-only-template', function () {

function assertComputed(element, value, pseudo) {
var computed = getComputedStyle(element, pseudo);
assert.equal(computed['border-top-width'], value, 'computed style incorrect');
}

test('elements without templates do not call ShadyCSS', () => {
let el = document.createElement('x-foo');
document.body.appendChild(el);
assert.ok(el.spy);
assert.isTrue(el.spy.notCalled);
});

test('dom-repeat and dom-if do not break custom-style', () => {
// force custom-style flushing
let target = document.querySelector('#target');
window.ShadyCSS.styleDocument();
assertComputed(target, '2px');
});
});
</script>
</body>
8 changes: 1 addition & 7 deletions test/unit/styling-scoped.html
Original file line number Diff line number Diff line change
Expand Up @@ -759,13 +759,7 @@
Polymer.flush();
assert.notInclude(d.getAttribute('style-scoped') || '', styled.is, 'scoping attribute not removed when added to other root');
assert.notInclude(d.className, styled.is, 'scoping class not removed when added to other root');
Polymer.dom(styled.root).appendChild(d);
Polymer.flush();
assertComputed(d, '4px');
Polymer.dom(styled.root).removeChild(d);
Polymer.flush();
assert.notInclude(d.getAttribute('style-scoped') || '', styled.is, 'scoping attribute not removed when removed from root');
assert.notInclude(d.className, styled.is, 'scoping class not removed when removed from root');
assertComputed(d, '0px');
Polymer.dom(styled.root).appendChild(d);
Polymer.flush();
assertComputed(d, '4px');
Expand Down

0 comments on commit cd321a3

Please sign in to comment.