only warnings are for mixins, which is not implemented

This commit is contained in:
Daniel Freedman
2017-01-12 15:55:12 -08:00
parent 9e0ab9fdb6
commit e90fc863cf
20 changed files with 306 additions and 158 deletions

View File

@@ -1,4 +1,5 @@
window.Polymer = {};
function Polymer(){}
let customElements = {
@@ -14,8 +15,6 @@ let HTMLImports = {
window.HTMLImports = HTMLImports;
let addEventListener = window.addEventListener;
let ShadyCSS = {
applyStyle(){},
updateStyles(){},
@@ -39,12 +38,25 @@ window.ShadyDOM = ShadyDOM;
let WebComponents = {};
window.WebComponents = WebComponents;
Event.prototype.composed = false;
HTMLElement.prototype.attachShadow = function(){};
/**
* @type {boolean}
*/
Event.prototype.composed;
/**
* @record
* @return {!Array<!(Element|ShadowRoot|Document|Window)>}
*/
Event.prototype.composedPath = function(){};
/**
* @param {!{mode: string}} options
* @return {!ShadowRoot}
*/
HTMLElement.prototype.attachShadow = function(options){};
/**
* @constructor
* @extends {HTMLElement}
*/
function CustomStyle(){}
/**
@@ -57,13 +69,13 @@ CustomStyle.prototype.processHook = function(style){};
*/
function CustomElement(){}
/**
* @type {Array<string> | undefined}
* @type {!Array<string> | undefined}
*/
CustomElement.observedAttributes;
CustomElement.prototype.connectedCallback = function(){};
CustomElement.prototype.disconnectedCallback = function(){};
/**
* @param {!string} attributeName
* @param {string} attributeName
* @param {?string} oldValue
* @param {?string} newValue
* @param {?string} namespaceURI
@@ -72,12 +84,41 @@ CustomElement.prototype.attributeChangedCallback = function(attributeName, oldVa
/**
* @constructor
* @extends HTMLElement
* @extends {HTMLElement}
*/
function HTMLSlotElement(){}
/**
* @param {{flatten: boolean} | undefined} options
* @return {Array<Node>}
* @param {!{flatten: boolean} | undefined} options
* @return {!Array<!Node>}
*/
HTMLSlotElement.prototype.assignedNodes = function(options){};
HTMLSlotElement.prototype.assignedNodes = function(options){};
/**
* @type {HTMLSlotElement}
*/
Node.prototype.assignedSlot;
/**
* @constructor
*/
function InputDeviceCapabilities(){}
/**
* @type {boolean}
*/
InputDeviceCapabilities.prototype.firesTouchEvents;
/**
* @type {InputDeviceCapabilities}
*/
MouseEvent.prototype.sourceCapabilities;
/**
* @type {Element}
*/
HTMLElement.prototype._activeElement;
/**
* @param {HTMLTemplateElement} template
*/
HTMLTemplateElement.prototype.decorate = function(template){};

View File

@@ -55,36 +55,27 @@ gulp.task('clean', function () {
const {Transform} = require('stream');
class LogStream extends Transform {
constructor(prefix) {
super({objectMode: true});
this.prefix = `${prefix || ''}:`;
}
_transform(file, enc, cb) {
console.log(this.prefix, file.path);
cb(null, file);
}
}
class OldNameStream extends Transform {
constructor(closureStream) {
constructor(fileList) {
super({objectMode: true});
this.fileList = closureStream.fileList_;
this.fileList = fileList;
}
_transform(file, enc, cb) {
const origFile = this.fileList.shift();
// console.log(`rename ${file.path} -> ${origFile.path}`)
file.path = origFile.path;
if (this.fileList) {
const origFile = this.fileList.shift();
// console.log(`rename ${file.path} -> ${origFile.path}`)
file.path = origFile.path;
}
cb(null, file);
}
_flush(cb) {
if (this.fileList.length > 0) {
if (this.fileList && this.fileList.length > 0) {
this.fileList.forEach((oldFile) => {
// console.log(`pumping fake file ${oldFile.path}`)
let newFile = oldFile.clone({deep: true, contents: false});
newFile.contents = new Buffer('');
this.push(newFile);
})
});
}
cb();
}
@@ -93,6 +84,7 @@ class OldNameStream extends Transform {
gulp.task('build', ['clean'], () => {
const closureStream = closure({
// debug: true,
// new_type_inf: true,
compilation_level: 'ADVANCED',
// compilation_level: 'SIMPLE',
@@ -107,7 +99,7 @@ gulp.task('build', ['clean'], () => {
const closurePipeline = lazypipe()
.pipe(() => closureStream)
.pipe(() => new OldNameStream(closureStream))
.pipe(() => new OldNameStream(closureStream.fileList_))
// process source files in the project
const sources = project.sources()

View File

@@ -20,7 +20,10 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
Polymer.Attributes = Polymer.Utils.dedupingMixin(function(superClass) {
return class Attributes extends superClass {
/**
* @unrestricted
*/
class Attributes extends superClass {
constructor() {
super();
@@ -66,7 +69,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
*
* @method _propertyToAttribute
* @param {string} property Property name to reflect.
* @param {*=} attribute Attribute name to reflect.
* @param {string=} attribute Attribute name to reflect.
* @param {*=} value Property value to refect.
*/
_propertyToAttribute(property, attribute, value) {
@@ -85,11 +88,10 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
* the attribute will be removed (this is the default for boolean
* type `false`).
*
* @method _valueToAttribute
* @param {Element=} node Element to set attribute to.
* @method _valueToNodeAttribute
* @param {Element} node Element to set attribute to.
* @param {*} value Value to serialize.
* @param {string} attribute Attribute name to serialize to.
*/
_valueToNodeAttribute(node, value, attribute) {
var str = this._serializeAttribute(value);
@@ -109,7 +111,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
*
* @method _serializeAttribute
* @param {*} value Property value to serialize.
* @return {string} String serialized from the provided property value.
* @return {string | undefined} String serialized from the provided property value.
*/
_serializeAttribute(value) {
/* eslint-disable no-fallthrough */
@@ -119,7 +121,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
case 'object':
if (value instanceof Date) {
return value;
return value.toString();
} else if (value) {
try {
return JSON.stringify(value);
@@ -129,7 +131,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
}
default:
return value != null ? value : undefined;
return value != null ? value.toString() : undefined;
}
}
@@ -152,18 +154,22 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
* @return {*} Typed value deserialized from the provided string.
*/
_deserializeAttribute(value, type) {
/**
* @type {*}
*/
let outValue;
switch (type) {
case Number:
value = Number(value);
outValue = Number(value);
break;
case Boolean:
value = (value !== null);
outValue = (value !== null);
break;
case Object:
try {
value = JSON.parse(value);
outValue = JSON.parse(value);
} catch(x) {
// allow non-JSON literals like Strings and Numbers
}
@@ -171,26 +177,31 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
case Array:
try {
value = JSON.parse(value);
outValue = JSON.parse(value);
} catch(x) {
value = null;
outValue = null;
console.warn('Polymer::Attributes: couldn`t decode Array as JSON');
}
break;
case Date:
value = new Date(value);
outValue = new Date(value);
break;
case String:
default:
break;
}
return value;
if (!outValue) {
outValue = value;
}
return outValue;
}
/* eslint-enable no-fallthrough */
}
return Attributes;
});

View File

@@ -40,7 +40,11 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
Polymer.ElementMixin = Polymer.Utils.cachingMixin(function(base) {
const mixin = Polymer.PropertyEffects(base);
return class PolymerElement extends mixin {
/**
* @unrestricted
*/
class PolymerElement extends mixin {
// returns the config object on specifically on `this` class (not super)
// config is used for:
@@ -319,8 +323,10 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
* to put its dom in another location.
*
* @method _attachDom
* @throws {Error}
* @suppress {missingReturn}
* @param {NodeList} dom to attach to the element.
* @returns {Node} node to which the dom has been attached.
* @return {Node} node to which the dom has been attached.
*/
_attachDom(dom) {
if (this.attachShadow) {
@@ -337,6 +343,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
`Polymer.Element can
create dom as children instead of in ShadowDOM by setting
\`this.root = this;\` before \`ready\`.`);
}
}
@@ -350,6 +357,14 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
}
}
/**
* Update styling for this element
*
* @param {Object=} properties
* Override styling with an object of properties where the keys are css properties, and the values are strings
* Example: `this.updateStyles({'color': 'blue'})`
* These properties are retained unless a value of `null` is set.
*/
updateStyles(properties) {
if (window.ShadyCSS) {
ShadyCSS.applyStyle(this, properties);
@@ -378,6 +393,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
}
return PolymerElement;
});
let hostStack = {

View File

@@ -89,7 +89,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
detached() {}
attributeChanged() {}
attributeChanged(name, old, value) {}
serialize(value) {
return this._serializeAttribute(value);
@@ -157,8 +157,8 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
* template content.
*/
instanceTemplate(template) {
var dom =
document.importNode(template._content || template.content, true);
var dom = /** @type {DocumentFragment} */
(document.importNode(template._content || template.content, true));
return dom;
}
@@ -167,14 +167,14 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
* Dispatches a custom event with an optional detail value.
*
* @method fire
* @param {String} type Name of event type.
* @param {string} type Name of event type.
* @param {*=} detail Detail value containing event-specific
* payload.
* @param {Object=} options Object specifying options. These may include:
* `bubbles` (boolean, defaults to `true`),
* `cancelable` (boolean, defaults to false), and
* `node` on which to fire the event (HTMLElement, defaults to `this`).
* @return {CustomEvent} The new event that was fired.
* @return {Event} The new event that was fired.
*/
fire(type, detail, options) {
options = options || {};
@@ -341,7 +341,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
* returned by <a href="#getEffectiveChildNodes>getEffectiveChildNodes</a>.
*
* @method getEffectiveTextContent
* @return {Array<Node>} List of effctive children.
* @return {string} List of effctive children.
*/
getEffectiveTextContent() {
var cn = this.getEffectiveChildNodes();
@@ -433,7 +433,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
*
* @method isLocalDescendant
* @param {HTMLElement=} node The element to be checked.
* @return {Boolean} true if node is in this element's local DOM tree.
* @return {boolean} true if node is in this element's local DOM tree.
*/
isLocalDescendant(node) {
return this.root === node.getRootNode();
@@ -658,8 +658,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
/**
* Cross-platform helper for setting an element's CSS `transform` property.
*
* @method transformText
* @param {String} transform Transform setting.
* @param {string} transformText Transform setting.
* @param {HTMLElement=} node Element to apply the transform to.
* Defaults to `this`
*/
@@ -696,9 +695,9 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
* notification is generated**.
*
* @method arrayDelete
* @param {String|Array} path Path to array from which to remove the item
* @param {string | Array<number|string>} arrayOrPath Path to array from which to remove the item
* (or the array itself).
* @param {any} item Item to remove.
* @param {*} item Item to remove.
* @return {Array} Array containing item removed.
*/
arrayDelete(arrayOrPath, item) {
@@ -715,6 +714,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
return this.splice(arrayOrPath, index, 1);
}
}
return null;
}
}

View File

@@ -84,6 +84,9 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
}
};
/**
* @param {boolean=} setup
*/
function setupTeardownMouseCanceller(setup) {
let events = IS_TOUCH_ONLY ? ['click'] : MOUSE_EVENTS;
for (let i = 0, en; i < events.length; i++) {

View File

@@ -45,6 +45,10 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
return klass;
}
/**
* @param {Array} behaviors
* @param {Array=} list
*/
var flattenBehaviors = function(behaviors, list) {
list = list || [];
if (behaviors) {
@@ -84,6 +88,10 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
return behavior._template || super.getTemplate() || this.prototype._template;
}
/**
* @param {Function} fn
* @param {Array=} args
*/
_invokeFunction(fn, args) {
if (fn) {
fn.apply(this, args);

View File

@@ -28,6 +28,10 @@
static get observedAttributes() { return ['id'] }
get modules() {
return modules;
}
attributeChangedCallback(name, old, value) {
if (old !== value) {
this.register();
@@ -45,7 +49,7 @@
* when a dom-module is imperatively created. For
* example, `document.createElement('dom-module').register('foo')`.
* @method register
* @param {String} id The id at which to register the dom-module.
* @param {string=} id The id at which to register the dom-module.
*/
register(id) {
id = id || this.id;
@@ -64,9 +68,9 @@
* Retrieves the dom specified by `selector` in the module specified by
* `id`. For example, this.import('foo', 'img');
* @method register
* @param {String} id
* @param {String} selector
* @return {Object} Returns the dom which matches `selector` in the module
* @param {string} id
* @param {string=} selector
* @return {Element} Returns the dom which matches `selector` in the module
* at the specified `id`.
*/
import(id, selector) {
@@ -77,6 +81,7 @@
}
return m;
}
return null;
}
}
@@ -86,8 +91,6 @@
// export
Polymer.DomModule = new DomModule();
Polymer.DomModule.modules = modules;
})();
</script>

View File

@@ -234,7 +234,9 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
* Override this method to e.g. provide stricter checking for
* Objects/Arrays when using immutable patterns.
*
* @param {type} name Description
* @param {string} property
* @param {*} value
* @param {*} old
* @return {boolean} Whether the property should be considered a change
* and enqueue a `_proeprtiesChanged` callback
* @protected

View File

@@ -88,7 +88,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
* @param {Object} inst The instance with effects to run
* @param {string} type Type of effect to run
* @param {Object} props Bag of current property changes
* @param {Object} oldProps Bag of previous values for changed properties
* @param {Object=} oldProps Bag of previous values for changed properties
* @private
*/
function runEffects(inst, type, props, oldProps) {
@@ -183,7 +183,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
* `notify: true` to ensure object sub-property notifications were
* sent.
*
* @param {Object} inst The instance with effects to run
* @param {Element} inst The instance with effects to run
* @param {Object} props Bag of current property changes
* @param {Object} oldProps Bag of previous values for changed properties
* @private
@@ -219,6 +219,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
*
* @param {Element} inst The element from which to fire the event
* @param {string} path The path that was changed
* @param {*} value
* @private
*/
function notifyPath(inst, path, value) {
@@ -237,7 +238,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
* @param {Element} inst The element from which to fire the event
* @param {string} eventName The name of the event to send ('{property}-changed')
* @param {*} value The value of the changed property
* @param {string=} path If a sub-path of this property changed, the path
* @param {string | null | undefined} path If a sub-path of this property changed, the path
* that changed (optional).
* @private
*/
@@ -258,7 +259,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
* Dispatches a non-bubbling event named `info.eventName` on the instance
* with a detail object containing the new `value`.
*
* @param {Object} inst The instance the effect will be run on
* @param {Element} inst The instance the effect will be run on
* @param {string} property Name of property
* @param {*} value Current value of property
* @param {*} old Previous value of property
@@ -379,10 +380,10 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
* computed before other effects (binding propagation, observers, and notify)
* run.
*
* @param {Object} inst The instance the effect will be run on
* @param {Element} inst The instance the effect will be run on
* @param {Object} changedProps Bag of changed properties
* @param {Object} oldProps Bag of previous values for changed properties
* @return {Object} Bag of newly computed properties from "computed" effects
* @return {Object | null | undefined} Bag of newly computed properties from "computed" effects
*/
function runComputedEffects(inst, changedProps, oldProps) {
if (inst[TYPES.COMPUTE]) {
@@ -396,6 +397,8 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
inst.__dataPending = null;
}
return computedProps;
} else {
return undefined;
}
}
@@ -425,13 +428,14 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
* Computes path changes based on path links set up using the `linkPaths`
* API.
*
* @param {Object} inst The instance whose props are changing
* @param {Element} inst The instance whose props are changing
* @param {Object} changedProps Bag of changed properties
* @param {Object} computedProps Bag of properties newly computed this turn
* @param {Object | undefined} computedProps Bag of properties newly computed this turn
* via "computed" effects; any linked paths generated via this method
* will be added both to the set of `changedProps` as well as to the
* set of `computedProps`; this is because the `fromAbove: true` case will
* notify only from the `computedProps` bag.
* @return {Object | undefined}
* @private
*/
function computeLinkedPaths(inst, changedProps, computedProps) {
@@ -504,8 +508,8 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
/**
* Implements the "binding" (property/path binding) effect.
*
* @param {Object} inst The instance the effect will be run on
* @param {string} property Name of property
* @param {Element} inst The instance the effect will be run on
* @param {string} path Name of property
* @param {*} value Current value of property
* @param {*} old Previous value of property
* @param {Object} info Effect metadata
@@ -626,7 +630,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
*
* @param {Object} model Prototype or instance
* @param {Object} note Binding note returned from Annotator
* @param {number} part The compound part metadata
* @param {Object} part The compound part metadata
* @param {number} index Index into `__dataNodes` list of annotated nodes that the
* note applies to
* @private
@@ -871,9 +875,11 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
* optionally, for the method name if `dynamic` is true) that calls the
* provided effect function.
*
* @param {Object} inst Prototype or instance
* @param {Element | Object} model Prototype or instance
* @param {Object} sig Method signature metadata
* @param {string} type
* @param {Function} effectFn Function to run when arguments change
* @param {*=} methodInfo
* @param {boolean=} dynamic Whether the method name should be included as
* a dependency to the effect.
* @private
@@ -959,6 +965,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
return sig;
}
}
return null;
}
/**
@@ -1141,7 +1148,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
*
* Note: this implementation only accepts normalized paths
*
* @param {Object} inst Instance to send notifications to
* @param {Element} inst Instance to send notifications to
* @param {Array} array The array the mutations occurred on
* @param {string} path The path to the array that was mutated
* @param {Array} splices Array of splice records
@@ -1161,7 +1168,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
*
* Note: this implementation only accepts normalized paths
*
* @param {Object} inst Instance to send notifications to
* @param {Element} inst Instance to send notifications to
* @param {Array} array The array the mutations occurred on
* @param {string} path The path to the array that was mutated
* @param {number} index Index at which the array mutation occurred
@@ -1194,7 +1201,11 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
const mixin = Polymer.TemplateStamp(
Polymer.Attributes(Polymer.PropertyAccessors(superClass)));
return class PropertyEffects extends mixin {
/**
* @unrestricted
*/
class PropertyEffects extends mixin {
get PROPERTY_EFFECT_TYPES() {
return TYPES;
@@ -1272,7 +1283,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
*
* @param {string} path Property (or path) that should trigger the effect
* @param {string} type Effect type, from this.PROPERTY_EFFECT_TYPES
* @param {Object} effect Effect metadata object
* @param {Object=} effect Effect metadata object
* @protected
*/
_addPropertyEffect(path, type, effect) {
@@ -1300,7 +1311,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
* of a certain type.
*
* @param {string} property Property name
* @param {string} type Effect type, from this.PROPERTY_EFFECT_TYPES
* @param {string=} type Effect type, from this.PROPERTY_EFFECT_TYPES
* @return {boolean} True if the prototype/instance has an effect of this type
* @protected
*/
@@ -1374,11 +1385,11 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
* `path` can be a path string or array of path parts as accepted by the
* public API.
*
* @param {string} path Path to set
* @param {string | Array<number|string>} path Path to set
* @param {*} value Value to set
* @param {boolean} fromPath If the value being set was from a path; in
* @param {boolean=} fromPath If the value being set was from a path; in
* this case the value was shared, so no dirty check is performed.
* @return {?string} If the root of the path is a managed property,
* @return {string | undefined} If the root of the path is a managed property,
* returns a normalized string path suitable for setting into the system
* via `_setProperty`/`_setPendingProperty`. A null path is returned if
* a path was being set and fails a dirty check, unless `fromPath`
@@ -1405,11 +1416,13 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
path = Polymer.Path.set(this, path, value);
// Use property-accessor's simpler dirty check
if (!super._shouldPropertyChange(path, value, old)) {
return null;
return undefined;
}
}
if (hasEffect) {
return path;
} else {
return undefined;
}
}
@@ -1686,8 +1699,8 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
* are routed to the other.
*
* @method linkPaths
* @param {string} to Target path to link.
* @param {string} from Source path to link.
* @param {string | Array<string|number>} to Target path to link.
* @param {string | Array<string|number>} from Source path to link.
* @public
*/
linkPaths(to, from) {
@@ -1708,7 +1721,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
* linking the paths.
*
* @method unlinkPaths
* @param {string} path Target path to unlink.
* @param {string | Array<string|number>} path Target path to unlink.
* @public
*/
unlinkPaths(path) {
@@ -1749,7 +1762,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
*/
notifySplices(path, splices) {
let info = {};
let array = Polymer.Path.get(this, path, info);
let array = /** @type {Array} */(Polymer.Path.get(this, path, info));
notifySplices(this, array, info.path, splices);
}
@@ -1802,8 +1815,10 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
if (root) {
Polymer.Path.set(root, path, value);
} else {
if (!this._hasReadOnlyEffect(path)) {
if ((path = this._setPathOrUnmanagedProperty(path, value))) {
if (!this._hasReadOnlyEffect(/** @type {string} */(path))) {
/** @type {?string | undefined} */
let propPath;
if ((propPath = this._setPathOrUnmanagedProperty(path, value))) {
this._setProperty(path, value);
}
}
@@ -1820,14 +1835,14 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
* splice occurred to the array.
*
* @method push
* @param {String} path Path to array.
* @param {...any} var_args Items to push onto array
* @param {string} path Path to array.
* @param {...*} items Items to push onto array
* @return {number} New length of the array.
* @public
*/
push(path, ...items) {
let info = {};
let array = Polymer.Path.get(this, path, info);
let array = /** @type {Array}*/(Polymer.Path.get(this, path, info));
let len = array.length;
let ret = array.push(...items);
if (items.length) {
@@ -1846,13 +1861,13 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
* splice occurred to the array.
*
* @method pop
* @param {String} path Path to array.
* @return {any} Item that was removed.
* @param {string} path Path to array.
* @return {*} Item that was removed.
* @public
*/
pop(path) {
let info = {};
let array = Polymer.Path.get(this, path, info);
let array = /** @type {Array} */(Polymer.Path.get(this, path, info));
let hadLength = Boolean(array.length);
let ret = array.pop();
if (hadLength) {
@@ -1872,16 +1887,16 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
* splice occurred to the array.
*
* @method splice
* @param {String} path Path to array.
* @param {string} path Path to array.
* @param {number} start Index from which to start removing/inserting.
* @param {number} deleteCount Number of items to remove.
* @param {...any} var_args Items to insert into array.
* @param {...*} items Items to insert into array.
* @return {Array} Array of removed items.
* @public
*/
splice(path, start, deleteCount, ...items) {
let info = {};
let array = Polymer.Path.get(this, path, info);
let array = /** @type {Array} */(Polymer.Path.get(this, path, info));
// Normalize fancy native splice handling of crazy start values
if (start < 0) {
start = array.length - Math.floor(-start);
@@ -1908,13 +1923,13 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
* splice occurred to the array.
*
* @method shift
* @param {String} path Path to array.
* @return {any} Item that was removed.
* @param {string} path Path to array.
* @return {*} Item that was removed.
* @public
*/
shift(path) {
let info = {};
let array = Polymer.Path.get(this, path, info);
let array = /** @type {Array} */(Polymer.Path.get(this, path, info));
let hadLength = Boolean(array.length);
let ret = array.shift();
if (hadLength) {
@@ -1933,14 +1948,14 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
* splice occurred to the array.
*
* @method unshift
* @param {String} path Path to array.
* @param {...any} var_args Items to insert info array
* @param {string} path Path to array.
* @param {...*} items Items to insert info array
* @return {number} New length of the array.
* @public
*/
unshift(path, ...items) {
let info = {};
let array = Polymer.Path.get(this, path, info);
let array = /** @type {Array} */(Polymer.Path.get(this, path, info));
let ret = array.unshift(...items);
if (items.length) {
notifySplice(this, array, info.path, 0, items.length, []);
@@ -1961,16 +1976,18 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
* @public
*/
notifyPath(path, value) {
/** @type {string} */
let propPath;
if (arguments.length == 1) {
// Get value if not supplied
let info = {};
value = Polymer.Path.get(this, path, info);
path = info.path;
propPath = info.path;
} else if (Array.isArray(path)) {
// Normalize path if needed
path = Polymer.Path.normalize(path);
propPath = /** @type {string} */(Polymer.Path.normalize(path));
}
this._setProperty(path, value);
this._setProperty(propPath, value);
}
/**
@@ -2122,6 +2139,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
}
return PropertyEffects;
});
})();

View File

@@ -22,6 +22,11 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
}
return Polymer.DomModule.import(moduleId);
},
/**
* @param {string} moduleIds
* @param {boolean=} warnIfNotFound
* @return {string}
*/
cssFromModules(moduleIds, warnIfNotFound) {
var modules = moduleIds.trim().split(' ');
var cssText = '';

View File

@@ -217,7 +217,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
// TODO(sjmiles): is this for non-ELEMENT nodes? If so, we should
// change the contract of this method, or filter these out above.
if (element.attributes) {
parseNodeAttributeAnnotations(element, note, list);
parseNodeAttributeAnnotations(element, note);
// TODO(sorvell): ad hoc callback for doing work on elements while
// leveraging annotator's tree walk.
// Consider adding an node callback registry and moving specific

View File

@@ -112,7 +112,7 @@ Then the `observe` property should be configured as follows:
static get template() { return null; }
static get config() {
static get config() {
return {
@@ -423,6 +423,10 @@ Then the `observe` property should be configured as follows:
}
}
/**
* @param {Function} fn
* @param {?number=} delay
*/
_debounceRender(fn, delay) {
this._renderDebouncer =
Polymer.Debouncer.debounce(this._renderDebouncer, fn, delay, this);
@@ -571,7 +575,7 @@ Then the `observe` property should be configured as follows:
var dot = itemsPath.indexOf('.');
var itemsIdx = dot < 0 ? itemsPath : itemsPath.substring(0, dot);
// If path was index into array...
if (itemsIdx == parseInt(itemsIdx)) {
if (itemsIdx == parseInt(itemsIdx, 10)) {
var itemPath = dot < 0 ? '' : itemsPath.substring(dot+1);
// See if the item subpath should trigger a full refresh...
if (!this._handleObservedPaths(itemPath)) {
@@ -582,7 +586,7 @@ Then the `observe` property should be configured as follows:
inst.forwardProperty(this.as + (itemPath ? '.' + itemPath : ''), value);
inst.flushProperties();
}
}
}
return true;
}
}
@@ -597,7 +601,7 @@ Then the `observe` property should be configured as follows:
*
* @method itemForElement
* @param {HTMLElement} el Element for which to return the item.
* @return {any} Item associated with the element.
* @return {*} Item associated with the element.
*/
itemForElement(el) {
var instance = this.modelForElement(el);
@@ -611,7 +615,7 @@ Then the `observe` property should be configured as follows:
*
* @method indexForElement
* @param {HTMLElement} el Element for which to return the index.
* @return {any} Row index associated with the element (note this may
* @return {*} Row index associated with the element (note this may
* not correspond to the array index if a user `sort` is applied).
*/
indexForElement(el) {
@@ -634,7 +638,7 @@ Then the `observe` property should be configured as follows:
*
* @method modelForElement
* @param {HTMLElement} el Element for which to return a template model.
* @return {Object<Polymer.Base>} Model representing the binding scope for
* @return {Object} Model representing the binding scope for
* the element.
*/
modelForElement(el) {

View File

@@ -84,6 +84,9 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
_createTemplatizerClass(template, options) {
// Anonymous class created by the templatizer
/**
* @unrestricted
*/
var klass = class extends TemplateInstanceBase {
//TODO(kschaaf): for debugging; remove?
get localName() { return 'template#' + this.__template.id + '/TemplateInstance' }
@@ -267,7 +270,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
*
* @method modelForElement
* @param {HTMLElement} el Element for which to return a template model.
* @return {Object<Polymer.Base>} Model representing the binding scope for
* @return {Object} Model representing the binding scope for
* the element.
*/
modelForElement(host, el) {
@@ -290,6 +293,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
el = el.parentNode;
}
}
return null;
}
}

View File

@@ -9,8 +9,9 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
-->
<link rel="import" href="boot.html">
<script>
(function() {
Polymer.CaseMap = {
const CaseMap = {
_caseMap: {},
_rx: {
@@ -36,4 +37,6 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
};
Polymer.CaseMap = CaseMap;
})();
</script>

View File

@@ -12,55 +12,69 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
<link rel="import" href="async.html">
<script>
class Debouncer {
Polymer.Debouncer = function Debouncer(context) {
this.context = context;
var self = this;
this.boundFlush = function() {
self.flush();
};
};
constructor(context) {
this.context = context;
/** @type {Function} */
this.finish;
/** @type {Function} */
this.callback;
this.boundFlush = () => {this.flush()};
}
Polymer.Utils.mixin(Polymer.Debouncer.prototype, {
go: function(callback, wait) {
var h;
/**
* @param {Function} callback
* @param {?number=} wait
*/
go(callback, wait) {
let cancelToken;
this.finish = function() {
Polymer.Async.cancel(h);
Polymer.Async.cancel(cancelToken);
};
h = Polymer.Async.run(this.boundFlush, wait);
cancelToken = Polymer.Async.run(this.boundFlush, wait);
this.callback = callback;
},
}
cancel: function() {
cancel() {
if (this.finish) {
this.finish();
this.finish = null;
}
},
}
flush: function() {
flush() {
if (this.finish) {
this.cancel();
this.callback.call(this.context);
}
},
}
isActive: function() {
/**
* @return {boolean}
*/
isActive() {
return Boolean(this.finish);
}
});
Polymer.Debouncer.debounce = function(debouncer, callback, wait, context) {
context = context || this;
if (debouncer) {
debouncer.cancel();
} else {
debouncer = new Polymer.Debouncer(context);
/**
* @param {Debouncer} debouncer
* @param {Function} callback
* @param {?number=} wait
* @param {Object=} context
* @return {Debouncer}
*/
static debounce(debouncer, callback, wait, context) {
context = context || this;
if (debouncer) {
debouncer.cancel();
} else {
debouncer = new Debouncer(context);
}
debouncer.go(callback, wait);
return debouncer;
}
debouncer.go(callback, wait);
return debouncer;
};
}
Polymer.Debouncer = Debouncer;
</script>

View File

@@ -11,8 +11,9 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
<link rel="import" href="boot.html">
<script>
(function() {
Polymer.Path = {
const Path = {
isPath: function(path) {
return path.indexOf('.') >= 0;
@@ -54,7 +55,12 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
this.isDescendant(base, path);
},
// Converts array-based paths to flattened path, optionally split into array
/**
* Converts array-based paths to flattened path, optionally split into array
* @param {string | Array<string>} path
* @param {boolean=} split
* @return {string | Array<string>}
*/
normalize: function(path, split) {
if (Array.isArray(path)) {
var parts = [];
@@ -70,6 +76,12 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
}
},
/**
* @param {Object} root
* @param {string | Array<string|number>} path
* @param {Object=} info
* @return {*}
*/
get: function(root, path, info) {
var prop = root;
var parts = this.normalize(path, true);
@@ -111,4 +123,6 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
};
Polymer.Path = Path;
})();
</script>

View File

@@ -36,6 +36,11 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
class EffectiveNodesObserver {
constructor(target, callback) {
/** @type {MutationObserver} */
this.shadyChildrenObserver;
/** @type {MutationObserver} */
this.nativeChildrenObserver;
this.connected = false;
this.target = target;
this.callback = callback;
this.effectiveNodes = [];

View File

@@ -17,12 +17,12 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
}
if (window.WebComponents) {
addEventListener('WebComponentsReady', resolve);
window.addEventListener('WebComponentsReady', resolve);
} else {
if (document.readyState === 'interactive' || document.readyState === 'complete') {
resolve();
} else {
addEventListener('DOMContentLoaded', resolve);
window.addEventListener('DOMContentLoaded', resolve);
}
}

View File

@@ -100,6 +100,11 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
}
},
/**
* @template T
* @param {T} mixin
* @return {T}
*/
dedupingMixin(mixin) {
mixin = this.cachingMixin(mixin);
return function(base) {
@@ -125,16 +130,16 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
*
* @method importHref
* @param {string} href URL to document to load.
* @param {Function} onload Callback to notify when an import successfully
* @param {Function=} onload Callback to notify when an import successfully
* loaded.
* @param {Function} onerror Callback to notify when an import
* @param {Function=} onerror Callback to notify when an import
* unsuccessfully loaded.
* @param {boolean} optAsync True if the import should be loaded `async`.
* @param {boolean=} optAsync True if the import should be loaded `async`.
* Defaults to `false`.
* @return {HTMLLinkElement} The link element for the URL to be loaded.
*/
importHref(href, onload, onerror, optAsync) {
var l = document.createElement('link');
var l = /** @type {HTMLLinkElement} */(document.createElement('link'));
l.rel = 'import';
l.href = href;