Skip to content

Commit

Permalink
Merge branch 'master' into closure-warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
dfreedm committed Jun 15, 2017
2 parents c40eff6 + 0e19660 commit f7e2bd9
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 24 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Polymer 2.0 is released, and will be the future focus of Polymer development goi

## Overview

Polymer is a lightweight library built on top of the web standards-based [Web Components](http://webcomponents.org/) API's, and makes it easier to build your very own custom HTML elements. Creating reusable custom elements - and using elements built by others - can make building complex web applications easier and more efficient. By being based on the Web Components API's built in the browser (or [polyfilled](https://github.com/webcomponents/webcomponentsjs) where needed), Polymer elements are interoperable at the browser level, and can be used with other frameworks or libraries that work with modern browsers.
Polymer is a lightweight library built on top of the web standards-based [Web Components](http://webcomponents.org/) APIs, and makes it easier to build your very own custom HTML elements. Creating reusable custom elements - and using elements built by others - can make building complex web applications easier and more efficient. By being based on the Web Components API's built in the browser (or [polyfilled](https://github.com/webcomponents/webcomponentsjs) where needed), Polymer elements are interoperable at the browser level, and can be used with other frameworks or libraries that work with modern browsers.

Among many ways to leverage custom elements, they can be particularly useful for building reusable UI components. Instead of continually re-building a specific navigation bar or button in different frameworks and for different projects, you can define this element once using Polymer, and then reuse it throughout your project or in any future project.

Expand Down
32 changes: 14 additions & 18 deletions lib/elements/dom-repeat.html
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,6 @@
this.__itemsIdxToInstIdx = {};
this.__chunkCount = null;
this.__lastChunkTime = null;
this.__needFullRefresh = false;
this.__sortFn = null;
this.__filterFn = null;
this.__observePaths = null;
Expand Down Expand Up @@ -389,7 +388,6 @@
let methodHost = this.__getMethodHost();
this.__sortFn = sort && (typeof sort == 'function' ? sort :
function() { return methodHost[sort].apply(methodHost, arguments); });
this.__needFullRefresh = true;
if (this.items) {
this.__debounceRender(this.__render);
}
Expand All @@ -399,7 +397,6 @@
let methodHost = this.__getMethodHost();
this.__filterFn = filter && (typeof filter == 'function' ? filter :
function() { return methodHost[filter].apply(methodHost, arguments); });
this.__needFullRefresh = true;
if (this.items) {
this.__debounceRender(this.__render);
}
Expand Down Expand Up @@ -455,7 +452,6 @@
if (!this.__handleItemPath(change.path, change.value)) {
// Otherwise, the array was reset ('items') or spliced ('items.splices'),
// so queue a full refresh
this.__needFullRefresh = true;
this.__initializeChunking();
this.__debounceRender(this.__render);
}
Expand All @@ -467,7 +463,6 @@
let paths = this.__observePaths;
for (let i=0; i<paths.length; i++) {
if (path.indexOf(paths[i]) === 0) {
this.__needFullRefresh = true;
this.__debounceRender(this.__render, this.delay);
return true;
}
Expand Down Expand Up @@ -496,7 +491,6 @@
*/
render() {
// Queue this repeater, then flush all in order
this.__needFullRefresh = true;
this.__debounceRender(this.__render);
Polymer.flush();
}
Expand Down Expand Up @@ -629,18 +623,20 @@
// If path was index into array...
if (itemsIdx == parseInt(itemsIdx, 10)) {
let itemSubPath = dot < 0 ? '' : itemsPath.substring(dot+1);
// See if the item subpath should trigger a full refresh...
if (!this.__handleObservedPaths(itemSubPath)) {
// If not, forward to the instance for that index
let instIdx = this.__itemsIdxToInstIdx[itemsIdx];
let inst = this.__instances[instIdx];
if (inst) {
let itemPath = this.as + (itemSubPath ? '.' + itemSubPath : '');
// This is effectively `notifyPath`, but avoids some of the overhead
// of the public API
inst._setPendingPropertyOrPath(itemPath, value, false, true);
inst._flushProperties();
}
// If the path is observed, it will trigger a full refresh
this.__handleObservedPaths(itemSubPath);
// Note, even if a rull refresh is triggered, always do the path
// notification because unless mutableData is used for dom-repeat
// and all elements in the instance subtree, a full refresh may
// not trigger the proper update.
let instIdx = this.__itemsIdxToInstIdx[itemsIdx];
let inst = this.__instances[instIdx];
if (inst) {
let itemPath = this.as + (itemSubPath ? '.' + itemSubPath : '');
// This is effectively `notifyPath`, but avoids some of the overhead
// of the public API
inst._setPendingPropertyOrPath(itemPath, value, false, true);
inst._flushProperties();
}
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/legacy/class.html
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
// get template first from any imperative set in `info._template`
return info._template ||
// next look in dom-module associated with this element's is.
Polymer.DomModule.import(this.is, 'template') ||
Polymer.DomModule && Polymer.DomModule.import(this.is, 'template') ||
// next look for superclass template (note: use superclass symbol
// to ensure correct `this.is`)
Base.template ||
Expand Down
4 changes: 2 additions & 2 deletions lib/mixins/element-mixin.html
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@
*/
static get template() {
if (!this.hasOwnProperty(JSCompiler_renameProperty('_template', this))) {
this._template = Polymer.DomModule.import(
this._template = Polymer.DomModule && Polymer.DomModule.import(
/** @type PolymerElementConstructor*/ (this).is, 'template') ||
// note: implemented so a subclass can retrieve the super
// template; call the super impl this way so that `this` points
Expand All @@ -535,7 +535,7 @@
*/
static get importPath() {
if (!this.hasOwnProperty(JSCompiler_renameProperty('_importPath', this))) {
const module = Polymer.DomModule.import(/** @type PolymerElementConstructor */ (this).is);
const module = Polymer.DomModule && Polymer.DomModule.import(/** @type PolymerElementConstructor */ (this).is);
this._importPath = module ? module.assetpath : '' ||
Object.getPrototypeOf(/** @type PolymerElementConstructor*/ (this).prototype).constructor.importPath;
}
Expand Down
1 change: 1 addition & 0 deletions lib/mixins/gesture-event-listeners.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<link rel="import" href="../utils/boot.html">
<link rel="import" href="../utils/mixin.html">
<link rel="import" href="../utils/gestures.html">

<script>
Expand Down
2 changes: 1 addition & 1 deletion lib/mixins/property-effects.html
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,7 @@
const SQUOTE_STRING = '(?:' + '\'(?:[^\'\\\\]|\\\\.)*\'' + ')';
const DQUOTE_STRING = '(?:' + '"(?:[^"\\\\]|\\\\.)*"' + ')';
const STRING = '(?:' + SQUOTE_STRING + '|' + DQUOTE_STRING + ')';
const ARGUMENT = '(?:' + IDENT + '|' + NUMBER + '|' + STRING + '\\s*' + ')';
const ARGUMENT = '(?:(' + IDENT + '|' + NUMBER + '|' + STRING + ')\\s*' + ')';
const ARGUMENTS = '(?:' + ARGUMENT + '(?:,\\s*' + ARGUMENT + ')*' + ')';
const ARGUMENT_LIST = '(?:' + '\\(\\s*' +
'(?:' + ARGUMENTS + '?' + ')' +
Expand Down
18 changes: 18 additions & 0 deletions test/unit/dom-repeat.html
Original file line number Diff line number Diff line change
Expand Up @@ -4088,6 +4088,24 @@ <h4>x-repeat-chunked</h4>
assert(stamped[0].classList.contains('x-simple-repeat'), 'expected scoping');
});

test('paths update on observed properties', function() {
let simple = fixture('simple');
Polymer.flush();
//debugger;
var stamped = simple.root.querySelectorAll('*:not(template):not(dom-repeat)');
assert.equal(stamped[0].itemaProp, 'prop-1');
simple.$.repeat.observe = 'prop';
Polymer.flush();
simple.set('items.0.prop', {foo: 0});
Polymer.flush();
assert.equal(stamped[0].get('itemaProp.foo'), 0);
simple.set('items.0.prop.foo', 1);
Polymer.flush();
assert.equal(stamped[0].get('itemaProp.foo'), 1);
simple.set('items.0.prop.foo', 2);
Polymer.flush();
assert.equal(stamped[0].get('itemaProp.foo'), 2);
});
});

suite('timing', function() {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/property-effects-elements.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
computed-inline="{{computeInline(value,add, divide)}}"
computed-inline2="{{computeInline(value, add,divide)}}"
computed-inline3="{{computeInline(value, add,
divide)}}"
divide )}}"
computedattribute$="{{computeInline(value, add,divide)}}"
computedattribute2$="{{computeInline(
value, add, divide)}}"
Expand Down

0 comments on commit f7e2bd9

Please sign in to comment.