Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Applies micro-optimizations and removes obsolete settings #5591

Merged
merged 12 commits into from
Sep 23, 2019
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
language: node_js
sudo: false
dist: trusty
node_js: '9'
dist: xenial
node_js: '10'
services:
- xvfb
addons:
firefox: "66.0"
chrome: stable
cache:
directories:
- node_modules
firefox: latest
apt:
sources:
- google-chrome
packages:
- google-chrome-stable
before_script:
- npm install -g gulp-cli@1
- gulp lint-eslint
script:
- node ./node_modules/.bin/polymer test --npm --module-resolution=node -l chrome
- xvfb-run node ./node_modules/.bin/polymer test --npm --module-resolution=node -l firefox
- node ./node_modules/.bin/polymer test --npm --module-resolution=node -l firefox
- if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then travis_wait 30 ./util/travis-sauce-test.sh; fi
env:
global:
Expand Down
4 changes: 2 additions & 2 deletions lib/elements/dom-if.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { microTask } from '../utils/async.js';
import { root } from '../utils/path.js';
import { wrap } from '../utils/wrap.js';
import { hideElementsGlobally } from '../utils/hide-template-controls.js';
import { fastDomIf, strictTemplatePolicy } from '../utils/settings.js';
import { fastDomIf, strictTemplatePolicy, legacyOptimizations } from '../utils/settings.js';
import { showHideChildren, templatize } from '../utils/templatize.js';

/**
Expand Down Expand Up @@ -244,7 +244,7 @@ class DomIfBase extends PolymerElement {
this.__teardownInstance();
}
this._showHideChildren();
if (this.if != this._lastIf) {
if (!legacyOptimizations && this.if != this._lastIf) {
this.dispatchEvent(new CustomEvent('dom-change', {
bubbles: true,
composed: true
Expand Down
13 changes: 8 additions & 5 deletions lib/elements/dom-repeat.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { matches, translate } from '../utils/path.js';
import { timeOut, microTask } from '../utils/async.js';
import { wrap } from '../utils/wrap.js';
import { hideElementsGlobally } from '../utils/hide-template-controls.js';
import { legacyOptimizations } from '../utils/settings.js';

/**
* @constructor
Expand Down Expand Up @@ -239,7 +240,7 @@ export class DomRepeat extends domRepeatBase {
*/
renderedItemCount: {
type: Number,
notify: true,
notify: !legacyOptimizations,
readOnly: true
},

Expand Down Expand Up @@ -545,10 +546,12 @@ export class DomRepeat extends domRepeatBase {
// Set rendered item count
this._setRenderedItemCount(this.__instances.length);
// Notify users
this.dispatchEvent(new CustomEvent('dom-change', {
bubbles: true,
composed: true
}));
if (!legacyOptimizations) {
this.dispatchEvent(new CustomEvent('dom-change', {
bubbles: true,
composed: true
}));
}
// Check to see if we need to render more items
this.__tryRenderChunk();
}
Expand Down
13 changes: 11 additions & 2 deletions lib/mixins/properties-changed.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,15 @@ export const PropertiesChanged = dedupingMixin(
/* eslint-disable valid-jsdoc */
/** @this {PropertiesChanged} */
get() {
return this._getProperty(property);
// Inline for perf instead of using `_getProperty`
return this.__data[property];
},
/** @this {PropertiesChanged} */
set: readOnly ? function () {} : function (value) {
this._setProperty(property, value);
// Inline for perf instead of using `_setProperty`
if (this._setPendingProperty(property, value, true)) {
this._invalidateProperties();
}
}
/* eslint-enable */
});
Expand All @@ -180,6 +184,9 @@ export const PropertiesChanged = dedupingMixin(
this.__dataPending = null;
this.__dataOld = null;
this.__dataInstanceProps = null;
/** @type {number} */
// NOTE: used to track re-entrant calls to `_flushProperties`
this.__dataCounter = 0;
this.__serializing = false;
this._initializeProperties();
}
Expand Down Expand Up @@ -367,6 +374,7 @@ export const PropertiesChanged = dedupingMixin(
* @override
*/
_flushProperties() {
this.__dataCounter++;
const props = this.__data;
const changedProps = this.__dataPending;
const old = this.__dataOld;
Expand All @@ -375,6 +383,7 @@ export const PropertiesChanged = dedupingMixin(
this.__dataOld = null;
this._propertiesChanged(props, changedProps, old);
}
this.__dataCounter--;
}

/**
Expand Down
11 changes: 1 addition & 10 deletions lib/mixins/property-accessors.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import '../utils/boot.js';
import { dedupingMixin } from '../utils/mixin.js';
import { camelToDashCase, dashToCamelCase } from '../utils/case-map.js';
import { PropertiesChanged } from './properties-changed.js';
import { legacyNoBatch } from '../utils/settings.js';

// Save map of native properties; this forms a blacklist or properties
// that won't have their values "saved" by `saveAccessorValue`, since
Expand Down Expand Up @@ -295,15 +294,7 @@ export const PropertyAccessors = dedupingMixin(superClass => {
* @override
*/
_definePropertyAccessor(property, readOnly) {
if (legacyNoBatch) {
// Ensure properties are not flushed when adding instance effects
const ready = this.__dataReady;
this.__dataReady = false;
saveAccessorValue(this, property);
this.__dataReady = ready;
} else {
saveAccessorValue(this, property);
}
saveAccessorValue(this, property);
super._definePropertyAccessor(property, readOnly);
}

Expand Down
Loading