Skip to content

Commit

Permalink
Merge pull request #5305 from Polymer/aomarks-upstream
Browse files Browse the repository at this point in the history
Upstream a bunch of g3 changes.
  • Loading branch information
aomarks authored Jul 27, 2018
2 parents b2e47c4 + ac6011e commit 8f6a962
Show file tree
Hide file tree
Showing 14 changed files with 395 additions and 247 deletions.
18 changes: 9 additions & 9 deletions externs/closure-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ Polymer_PropertiesChanged.prototype._shouldPropertyChange = function(property, v
* @param {string} name Name of attribute that changed
* @param {?string} old Old attribute value
* @param {?string} value New attribute value
* @param {?string} namespace Attribute namespace.
* @param {?string} namespace Namespace of the attribute
* @return {void}
*/
Polymer_PropertiesChanged.prototype.attributeChangedCallback = function(name, old, value, namespace){};
Expand Down Expand Up @@ -260,9 +260,9 @@ Polymer_TemplateStamp.prototype._removeEventListenerFromNode = function(node, ev
*/
Polymer_TemplateStamp._parseTemplate = function(template, outerTemplateInfo){};
/**
* @param {*} template
* @param {*} templateInfo
* @param {*} nodeInfo
* @param {*} template
* @param {*} templateInfo
* @param {*} nodeInfo
*/
Polymer_TemplateStamp._parseTemplateContent = function(template, templateInfo, nodeInfo){};
/**
Expand Down Expand Up @@ -760,7 +760,7 @@ Polymer_PropertyEffects._addTemplatePropertyEffect = function(templateInfo, prop
*/
Polymer_PropertyEffects._parseBindings = function(text, templateInfo){};
/**
* @param {this} inst Element that should be used as scope for
* @param {Element} inst Element that should be used as scope for
binding dependencies
* @param {BindingPart} part Binding part metadata
* @param {string} path Property/path that triggered this effect
Expand Down Expand Up @@ -973,7 +973,7 @@ Polymer_LegacyElementMixin.prototype._initializeProperties = function(){};
* @param {string} name Name of attribute.
* @param {?string} old Old value of attribute.
* @param {?string} value Current value of attribute.
* @param {?string} namespace Attribute namespace.
* @param {?string} namespace Namespace of the attribute
* @return {void}
*/
Polymer_LegacyElementMixin.prototype.attributeChangedCallback = function(name, old, value, namespace){};
Expand Down Expand Up @@ -1174,7 +1174,7 @@ Polymer_LegacyElementMixin.prototype.getComputedStyleValue = function(property){
* @param {string} jobName String to identify the debounce job.
* @param {function (): void} callback Function that is called (with `this`
context) when the wait time elapses.
* @param {number} wait Optional wait time in milliseconds (ms) after the
* @param {number=} wait Optional wait time in milliseconds (ms) after the
last signal that must elapse before invoking `callback`
* @return {!Object}
*/
Expand Down Expand Up @@ -1404,12 +1404,12 @@ Polymer_DisableUpgradeMixin.prototype._enableProperties = function(){};
/**
* @override
*/
Polymer_DisableUpgradeMixin.prototype.attributeChangedCallback = function(name, old, value, namespace){};
Polymer_DisableUpgradeMixin.prototype.attributeChangedCallback = function(name, old, value){};
/**
* @override
*/
Polymer_DisableUpgradeMixin.prototype.connectedCallback = function(){};
/**
* @override
*/
Polymer_DisableUpgradeMixin.prototype.disconnectedCallback = function(){};
Polymer_DisableUpgradeMixin.prototype.disconnectedCallback = function(){};
80 changes: 67 additions & 13 deletions externs/polymer-externs.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,23 @@

/**
* @typedef {{
* type: !Function,
* value: *,
* readOnly: (boolean | undefined),
* computed: (string | undefined),
* reflectToAttribute: (boolean | undefined),
* notify: (boolean | undefined),
* observer: (string | function(*,*) | undefined)
* type: !Function,
* value: (* | undefined),
* readOnly: (boolean | undefined),
* computed: (string | undefined),
* reflectToAttribute: (boolean | undefined),
* notify: (boolean | undefined),
* observer: (string | function(this:?, ?, ?) | undefined)
* }}
*/
let PolymerElementPropertiesMeta;

/**
* @typedef {Object<string, !PolymerElementPropertiesMeta>}
* @typedef {Object<string, !Function|!PolymerElementPropertiesMeta>}
*/
let PolymerElementProperties;

/** @record */
let PolymerInit = function(){};
/** @type {string} */
PolymerInit.prototype.is;
Expand Down Expand Up @@ -59,19 +60,19 @@ PolymerElementConstructor.observers;
/** @type {(!HTMLTemplateElement | string | undefined)} */
PolymerElementConstructor.template;

/** @interface */
let PropertiesMixinConstructor = function (){};
/** @type {(!PolymerElementProperties | undefined)} */
PropertiesMixinConstructor.properties;
PropertiesMixinConstructor.prototype.properties;
/** @return {void} */
PropertiesMixinConstructor.prototype.finalize = function() {};

/**
* @param {!PolymerInit} init
* @return {!function(new:HTMLElement)}
*/
function Polymer(init){}

/** @type {PolymerElementProperties} */
Polymer.ElementProperties;

/**
* @type {(function(*,string,string,Node):*)|undefined}
*/
Expand All @@ -95,7 +96,7 @@ PolymerTelemetry._regLog;
/** @type {function(HTMLElement)} */
PolymerTelemetry.register;
/** @type {function(HTMLElement)} */
PolymerTelemetry.dumpRegistrations;;
PolymerTelemetry.dumpRegistrations;

/** @type {PolymerTelemetry} */
Polymer.telemetry;
Expand All @@ -110,3 +111,56 @@ Polymer.version;
* @implements {Polymer_LegacyElementMixin}
*/
var PolymerElement = function() {};

/**
* On create callback.
* @override
*/
PolymerElement.prototype.created = function() {};
/**
* On ready callback.
* @override
*/
PolymerElement.prototype.ready = function() {};
/** On registered callback. */
PolymerElement.prototype.registered = function() {};
/**
* On attached to the DOM callback.
* @override
*/
PolymerElement.prototype.attached = function() {};
/**
* On detached from the DOM callback.
* @override
*/
PolymerElement.prototype.detached = function() {};

/**
* @typedef {{
* index: number,
* removed: !Array,
* addedCount: number,
* object: !Array,
* type: string,
* }}
*/
var PolymerSplice;
/**
* @typedef {{
* indexSplices: ?Array<!PolymerSplice>,
* }}
*/
var PolymerSpliceChange;

/**
* The type of the object received by an observer function when deep
* sub-property observation is enabled. See:
* https://www.polymer-project.org/2.0/docs/devguide/observers#deep-observation
*
* @typedef {{
* path: string,
* value: (?Object|undefined),
* base: (?Object|undefined)
* }}
*/
var PolymerDeepPropertyChange;
1 change: 1 addition & 0 deletions externs/polymer-internal-shared-types.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/**
* @fileoverview Internal shared types for Polymer
* @externs
*
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
Expand Down
1 change: 1 addition & 0 deletions lib/elements/dom-module.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export class DomModule extends HTMLElement {
* @param {?string} value Current value of attribute.
* @param {?string} namespace Attribute namespace.
* @return {void}
* @override
*/
attributeChangedCallback(name, old, value, namespace) {
if (old !== value) {
Expand Down
2 changes: 1 addition & 1 deletion lib/legacy/legacy-element-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ export const LegacyElementMixin = dedupingMixin((base) => {
* @return {void}
*/
setScrollDirection(direction, node) {
setTouchAction( (node || this), DIRECTION_MAP[direction] || 'auto');
setTouchAction(/** @type {Element} */ (node || this), DIRECTION_MAP[direction] || 'auto');
}
/* **** End Events **** */

Expand Down
64 changes: 47 additions & 17 deletions lib/legacy/polymer.dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,23 +231,6 @@ function forwardProperties(proto, properties) {
}
}

forwardMethods(DomApi.prototype, [
'cloneNode', 'appendChild', 'insertBefore', 'removeChild',
'replaceChild', 'setAttribute', 'removeAttribute',
'querySelector', 'querySelectorAll'
]);

forwardReadOnlyProperties(DomApi.prototype, [
'parentNode', 'firstChild', 'lastChild',
'nextSibling', 'previousSibling', 'firstElementChild',
'lastElementChild', 'nextElementSibling', 'previousElementSibling',
'childNodes', 'children', 'classList'
]);

forwardProperties(DomApi.prototype, [
'textContent', 'innerHTML'
]);


/**
* Event API wrapper class returned from `Polymer.dom.(target)` when
Expand Down Expand Up @@ -343,6 +326,53 @@ DomApi.prototype.querySelector;
*/
DomApi.prototype.querySelectorAll;

/** @type {?Node} */
DomApi.prototype.parentNode;
/** @type {?Node} */
DomApi.prototype.firstChild;
/** @type {?Node} */
DomApi.prototype.lastChild;
/** @type {?Node} */
DomApi.prototype.nextSibling;
/** @type {?Node} */
DomApi.prototype.previousSibling;
/** @type {?HTMLElement} */
DomApi.prototype.firstElementChild;
/** @type {?HTMLElement} */
DomApi.prototype.lastElementChild;
/** @type {?HTMLElement} */
DomApi.prototype.nextElementSibling;
/** @type {?HTMLElement} */
DomApi.prototype.previousElementSibling;
/** @type {!Array<!Node>} */
DomApi.prototype.childNodes;
/** @type {!Array<!HTMLElement>} */
DomApi.prototype.children;
/** @type {?DOMTokenList} */
DomApi.prototype.classList;

/** @type {string} */
DomApi.prototype.textContent;
/** @type {string} */
DomApi.prototype.innerHTML;

forwardMethods(DomApi.prototype, [
'cloneNode', 'appendChild', 'insertBefore', 'removeChild',
'replaceChild', 'setAttribute', 'removeAttribute',
'querySelector', 'querySelectorAll'
]);

forwardReadOnlyProperties(DomApi.prototype, [
'parentNode', 'firstChild', 'lastChild',
'nextSibling', 'previousSibling', 'firstElementChild',
'lastElementChild', 'nextElementSibling', 'previousElementSibling',
'childNodes', 'children', 'classList'
]);

forwardProperties(DomApi.prototype, [
'textContent', 'innerHTML'
]);

/**
* Legacy DOM and Event manipulation API wrapper factory used to abstract
* differences between native Shadow DOM and "Shady DOM" when polyfilling on
Expand Down
78 changes: 41 additions & 37 deletions lib/mixins/gesture-event-listeners.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,45 +29,49 @@ const gestures = gestures$0;
* cross-platform
* gesture events to nodes
*/
export const GestureEventListeners = dedupingMixin(superClass => {

/**
* @polymer
* @mixinClass
* @implements {Polymer_GestureEventListeners}
*/
class GestureEventListeners extends superClass {

export const GestureEventListeners = dedupingMixin(
/**
* Add the event listener to the node if it is a gestures event.
*
* @param {!Node} node Node to add event listener to
* @param {string} eventName Name of event
* @param {function(!Event):void} handler Listener function to add
* @return {void}
* @template T
* @param {function(new:T)} superClass Class to apply mixin to.
* @return {function(new:T)} superClass with mixin applied.
*/
_addEventListenerToNode(node, eventName, handler) {
if (!gestures.addListener(node, eventName, handler)) {
super._addEventListenerToNode(node, eventName, handler);
}
}
(superClass) => {
/**
* @polymer
* @mixinClass
* @implements {Polymer_GestureEventListeners}
*/
class GestureEventListeners extends superClass {
/**
* Add the event listener to the node if it is a gestures event.
*
* @param {!Node} node Node to add event listener to
* @param {string} eventName Name of event
* @param {function(!Event):void} handler Listener function to add
* @return {void}
* @override
*/
_addEventListenerToNode(node, eventName, handler) {
if (!gestures.addListener(node, eventName, handler)) {
super._addEventListenerToNode(node, eventName, handler);
}
}

/**
* Remove the event listener to the node if it is a gestures event.
*
* @param {!Node} node Node to remove event listener from
* @param {string} eventName Name of event
* @param {function(!Event):void} handler Listener function to remove
* @return {void}
*/
_removeEventListenerFromNode(node, eventName, handler) {
if (!gestures.removeListener(node, eventName, handler)) {
super._removeEventListenerFromNode(node, eventName, handler);
/**
* Remove the event listener to the node if it is a gestures event.
*
* @param {!Node} node Node to remove event listener from
* @param {string} eventName Name of event
* @param {function(!Event):void} handler Listener function to remove
* @return {void}
* @override
*/
_removeEventListenerFromNode(node, eventName, handler) {
if (!gestures.removeListener(node, eventName, handler)) {
super._removeEventListenerFromNode(node, eventName, handler);
}
}
}
}

}

return GestureEventListeners;

});
return GestureEventListeners;
});
Loading

0 comments on commit 8f6a962

Please sign in to comment.