Merge branch 'master' into shady-linked

This commit is contained in:
Steven Orvell 2015-11-30 14:45:31 -08:00
commit 014e61d47e
13 changed files with 146 additions and 20 deletions

View File

@ -90,7 +90,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
},
_bindingRegex: (function() {
var IDENT = '(?:' + '[a-zA-Z_$][\\w.:$-]*' + ')';
var IDENT = '(?:' + '[a-zA-Z_$][\\w.:$-*]*' + ')';
var NUMBER = '(?:' + '[-+]?[0-9]*\\.?[0-9]+(?:[eE][-+]?[0-9]+)?' + ')';
var SQUOTE_STRING = '(?:' + '\'(?:[^\'\\\\]|\\\\.)*\'' + ')';
var DQUOTE_STRING = '(?:' + '"(?:[^"\\\\]|\\\\.)*"' + ')';

View File

@ -146,6 +146,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
// for calling via doBehavior (e.g. created, ready)
Polymer.Base._behaviorProperties = {
hostAttributes: true,
beforeRegister: true,
registered: true,
properties: true,
observers: true,

View File

@ -161,7 +161,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
} else {
for (var i=0, arg; (i<sig.args.length) && (arg=sig.args[i]); i++) {
if (!arg.literal) {
this.__addAnnotatedComputationEffect(arg.model, index, note, part,
this.__addAnnotatedComputationEffect(arg.model, index, note, part,
arg);
}
}
@ -289,11 +289,13 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
(node.localName == 'input' && property == 'value')) {
value = value == undefined ? '' : value;
}
// setProperty using fromAbove to avoid spinning the wheel needlessly.
// Ideally we would call setProperty using fromAbove: true to avoid
// spinning the wheel needlessly, but we found that users were listening
// for change events outside of bindings
var pinfo;
if (!node._propertyInfo || !(pinfo = node._propertyInfo[property]) ||
if (!node._propertyInfo || !(pinfo = node._propertyInfo[property]) ||
!pinfo.readOnly) {
this.__setProperty(property, value, true, node);
this.__setProperty(property, value, false, node);
}
}
},

View File

@ -168,6 +168,8 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
function untrackDocument(stateObj) {
document.removeEventListener('mousemove', stateObj.movefn);
document.removeEventListener('mouseup', stateObj.upfn);
stateObj.movefn = null;
stateObj.upfn = null;
}
var Gestures = {
@ -416,8 +418,8 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
emits: ['down', 'up'],
info: {
movefn: function(){},
upfn: function(){}
movefn: null,
upfn: null
},
reset: function() {
@ -486,8 +488,8 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
}
this.moves.push(move);
},
movefn: function(){},
upfn: function(){},
movefn: null,
upfn: null,
prevent: false
},

View File

@ -68,7 +68,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
}
}
cssText += styleUtil.cssFromModule(this.is);
// check if we have a disconnected template and add styles from that
// check if we have a disconnected template and add styles from that
// if so; if our template has no parent or is not in our dom-module...
var p = this._template && this._template.parentNode;
if (this._template && (!p || p.id.toLowerCase() !== this.is)) {
@ -129,10 +129,12 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
var self = this;
var scopify = function(node) {
if (node.nodeType === Node.ELEMENT_NODE) {
node.className = self._scopeElementClass(node, node.className);
var className = node.getAttribute('class');
node.setAttribute('class', self._scopeElementClass(node, className));
var n$ = node.querySelectorAll('*');
for (var i=0, n; (i<n$.length) && (n=n$[i]); i++) {
n.className = self._scopeElementClass(n, n.className);
className = n.getAttribute('class');
n.setAttribute('class', self._scopeElementClass(n, className));
}
}
};

View File

@ -402,7 +402,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
* Checks whether an element is in this element's light DOM tree.
*
* @method isLightDescendant
* @param {HTMLElement=} node The element to be checked.
* @param {?Node} node The element to be checked.
* @return {Boolean} true if node is in this element's light DOM tree.
*/
isLightDescendant: function(node) {

View File

@ -13,6 +13,7 @@
neg-computed-inline="{{!computeInline(value,add,divide)}}"
computed-negative-number="{{computeNegativeNumber(-1)}}"
computed-negative-literal="{{computeNegativeNumber(-A)}}"
computed-wildcard="{{computeWildcard(a, b.*)}}"
style$="{{boundStyle}}"
data-id$="{{dataSetId}}"
custom-event-value="{{customEventValue::custom}}"
@ -256,6 +257,9 @@
},
computeCompound: function(a, b, c) {
return '' + c + b + a;
},
computeWildcard: function(a, bInfo) {
return a + (bInfo && bInfo.base ? bInfo.base.value : 0);
}
});
</script>

View File

@ -269,6 +269,12 @@ suite('single-element binding effects', function() {
assert.equal(el.$.boundChild.computedNegativeLiteral, undefined);
});
test('computed binding with wildcard', function() {
el.a = 5;
el.b = {value: 10};
assert.equal(el.$.boundChild.computedWildcard, 15);
});
});
</script>
@ -369,6 +375,15 @@ suite('2-way binding effects between elements', function() {
assert.equal(el.boundreadonlyvalue, 46, 'property bound to read-only property should change from change to bound value');
});
test('listener for value-changed fires when value changed from host', function() {
var listener = sinon.spy();
el.$.basic1.addEventListener('notifyingvalue-changed', listener);
el.boundnotifyingvalue = 678;
assert.equal(el.$.basic1.notifyingvalue, 678);
assert.isTrue(listener.calledOnce);
assert.equal(listener.getCalls()[0].args[0].detail.value, 678);
});
});
suite('1-way binding effects between elements', function() {

View File

@ -3648,6 +3648,16 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
suite('chunked rendering', function() {
// Patch requestAnimationFrame to setTimeout to reduce IE test flakiness on CI
var rAF;
suiteSetup(function() {
rAF = window.requestAnimationFrame;
window.requestAnimationFrame = setTimeout;
});
suiteTeardown(function() {
window.requestAnimationFrame = rAF;
});
test('basic chunked rendering', function(done) {
var checkItemOrder = function(stamped) {

View File

@ -148,7 +148,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
stream: {
type: Array,
value: function() {
return [];
return [];
}
}
},

View File

@ -406,6 +406,45 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
assert.equal(el.stream.length, 1);
});
});
suite('Reference Cleanup', function() {
var el;
setup(function() {
el = document.createElement('x-buttons');
document.body.appendChild(el);
});
teardown(function() {
document.body.removeChild(el);
});
test('down and up clear document tracking', function() {
var ev = new CustomEvent('mousedown', {bubbles: true});
el.dispatchEvent(ev);
// some recognizers do not track the document, like tap
var recognizers = Polymer.Gestures.recognizers.filter(function(r) {
return r.info.hasOwnProperty('movefn') &&
r.info.hasOwnProperty('upfn');
});
assert.isAbove(recognizers.length, 0, 'some recognizers track the document');
recognizers.forEach(function(r) {
assert.isFunction(r.info.movefn, r.name + ' movefn');
assert.isFunction(r.info.upfn, r.name + ' upfn');
});
ev = new CustomEvent('mouseup', {bubbles: true});
el.dispatchEvent(ev);
recognizers.forEach(function(r) {
assert.isNull(r.info.movefn, r.name + ' movefn');
assert.isNull(r.info.upfn, r.name + ' upfn');
});
});
});
</script>
</body>

View File

@ -308,4 +308,41 @@
}
});
})();
</script>
</script>
<template id="svg">
<svg class="svg" viewBox="0 0 24 24">
<circle id="circle" r="12" cx="12" cy="12" />
</svg>
</template>
<dom-module id="x-dynamic-svg">
<template>
<style>
.svg {
height: 24px;
width: 24px;
}
#circle {
fill: red;
fill-opacity: 0.5;
}
</style>
<div id="container"></div>
</template>
<script>
(function() {
var doc = document._currentScript.ownerDocument;
var template = doc.querySelector('template#svg');
Polymer({
is: 'x-dynamic-svg',
ready: function() {
this.scopeSubtree(this.$.container, true);
var dom = document.importNode(template.content, true);
this.$.container.appendChild(dom);
}
});
})();
</script>
</dom-module>

View File

@ -43,6 +43,8 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
<span id="dom-bind-dynamic" class$="[[dynamic]]">[[dynamic]]</span>
</template>
<x-dynamic-svg></x-dynamic-svg>
<script>
suite('scoped-styling', function() {
@ -61,7 +63,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
test(':host, :host(...)', function() {
assertComputed(styled, '1px');
assertComputed(styledWide, '2px');
});
test(':host-context(...)', function() {
@ -210,8 +212,9 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
test('styles shimmed in registration order', function() {
var s$ = document.head.querySelectorAll('style[scope]');
var expected = ['x-gchild', 'x-child2', 'x-styled', 'x-button',
'x-mixed-case', 'x-mixed-case-button', 'x-dynamic-scope', 'x-dynamic-template'];
var expected = ['x-gchild', 'x-child2', 'x-styled', 'x-button',
'x-mixed-case', 'x-mixed-case-button', 'x-dynamic-scope',
'x-dynamic-template', 'x-dynamic-svg'];
var actual = [];
for (var i=0; i<s$.length; i++) {
actual.push(s$[i].getAttribute('scope'));
@ -252,10 +255,21 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
x = document.createElement('button', 'x-mixed-case-button');
document.body.appendChild(x);
assertComputed(x, '14px');
});
});
test('svg classes are dynamically scoped correctly', function() {
var container = document.querySelector('x-dynamic-svg').$.container;
var svg = container.querySelector('.svg');
var computed = getComputedStyle(svg);
assert.equal(computed.height, '24px');
assert.equal(computed.width, '24px');
var circle = container.querySelector('#circle');
computed = getComputedStyle(circle);
assert.equal(computed['fill-opacity'], '0.5');
});
});
</script>