From 4a24ba3c0fd227d6c36abe7575f2b193f26e747a Mon Sep 17 00:00:00 2001 From: Kevin Schaaf Date: Wed, 6 Feb 2019 09:39:58 -0800 Subject: [PATCH] Refactor symbols to make gen-typescript-declarations happy --- lib/legacy/polymer.dom.js | 77 +++++++++++++++++++-------------------- 1 file changed, 38 insertions(+), 39 deletions(-) diff --git a/lib/legacy/polymer.dom.js b/lib/legacy/polymer.dom.js index 09502a19ae..360221c691 100644 --- a/lib/legacy/polymer.dom.js +++ b/lib/legacy/polymer.dom.js @@ -42,7 +42,7 @@ export const matchesSelector = function(node, selector) { * @implements {PolymerDomApi} * @unrestricted */ -class DomApi { +class DomApiNative { /** * @param {Node} node Node for which to create a Polymer.dom helper object. @@ -210,7 +210,7 @@ function forwardMethods(proto, methods) { for (let i=0; i < methods.length; i++) { let method = methods[i]; /* eslint-disable valid-jsdoc */ - proto[method] = /** @this {DomApi} */ function() { + proto[method] = /** @this {DomApiNative} */ function() { return this.node[method].apply(this.node, arguments); }; /* eslint-enable */ @@ -222,7 +222,7 @@ function forwardReadOnlyProperties(proto, properties) { let name = properties[i]; Object.defineProperty(proto, name, { get: function() { - const domApi = /** @type {DomApi} */(this); + const domApi = /** @type {DomApiNative} */(this); return domApi.node[name]; }, configurable: true @@ -235,14 +235,14 @@ function forwardProperties(proto, properties) { let name = properties[i]; Object.defineProperty(proto, name, { /** - * @this {DomApi} + * @this {DomApiNative} * @return {*} . */ get: function() { return this.node[name]; }, /** - * @this {DomApi} + * @this {DomApiNative} * @param {*} value . */ set: function(value) { @@ -295,90 +295,90 @@ export class EventApi { * @param {boolean=} deep * @return {!Node} */ -DomApi.prototype.cloneNode; +DomApiNative.prototype.cloneNode; /** * @function * @param {!Node} node * @return {!Node} */ -DomApi.prototype.appendChild; +DomApiNative.prototype.appendChild; /** * @function * @param {!Node} newChild * @param {Node} refChild * @return {!Node} */ -DomApi.prototype.insertBefore; +DomApiNative.prototype.insertBefore; /** * @function * @param {!Node} node * @return {!Node} */ -DomApi.prototype.removeChild; +DomApiNative.prototype.removeChild; /** * @function * @param {!Node} oldChild * @param {!Node} newChild * @return {!Node} */ -DomApi.prototype.replaceChild; +DomApiNative.prototype.replaceChild; /** * @function * @param {string} name * @param {string} value * @return {void} */ -DomApi.prototype.setAttribute; +DomApiNative.prototype.setAttribute; /** * @function * @param {string} name * @return {void} */ -DomApi.prototype.removeAttribute; +DomApiNative.prototype.removeAttribute; /** * @function * @param {string} selector * @return {?Element} */ -DomApi.prototype.querySelector; +DomApiNative.prototype.querySelector; /** * @function * @param {string} selector * @return {!NodeList} */ -DomApi.prototype.querySelectorAll; +DomApiNative.prototype.querySelectorAll; /** @type {?Node} */ -DomApi.prototype.parentNode; +DomApiNative.prototype.parentNode; /** @type {?Node} */ -DomApi.prototype.firstChild; +DomApiNative.prototype.firstChild; /** @type {?Node} */ -DomApi.prototype.lastChild; +DomApiNative.prototype.lastChild; /** @type {?Node} */ -DomApi.prototype.nextSibling; +DomApiNative.prototype.nextSibling; /** @type {?Node} */ -DomApi.prototype.previousSibling; +DomApiNative.prototype.previousSibling; /** @type {?HTMLElement} */ -DomApi.prototype.firstElementChild; +DomApiNative.prototype.firstElementChild; /** @type {?HTMLElement} */ -DomApi.prototype.lastElementChild; +DomApiNative.prototype.lastElementChild; /** @type {?HTMLElement} */ -DomApi.prototype.nextElementSibling; +DomApiNative.prototype.nextElementSibling; /** @type {?HTMLElement} */ -DomApi.prototype.previousElementSibling; +DomApiNative.prototype.previousElementSibling; /** @type {!Array} */ -DomApi.prototype.childNodes; +DomApiNative.prototype.childNodes; /** @type {!Array} */ -DomApi.prototype.children; +DomApiNative.prototype.children; /** @type {?DOMTokenList} */ -DomApi.prototype.classList; +DomApiNative.prototype.classList; /** @type {string} */ -DomApi.prototype.textContent; +DomApiNative.prototype.textContent; /** @type {string} */ -DomApi.prototype.innerHTML; +DomApiNative.prototype.innerHTML; -let DomApiImpl = DomApi; +let DomApiImpl = DomApiNative; if (window['ShadyDOM'] && window['ShadyDOM']['inUse'] && window['ShadyDOM']['noPatch'] && window['ShadyDOM']['Wrapper']) { @@ -389,9 +389,9 @@ if (window['ShadyDOM'] && window['ShadyDOM']['inUse'] && window['ShadyDOM']['noP class Wrapper extends window['ShadyDOM']['Wrapper'] {} // copy bespoke API onto wrapper - Object.getOwnPropertyNames(DomApi.prototype).forEach((prop) => { + Object.getOwnPropertyNames(DomApiNative.prototype).forEach((prop) => { if (prop != 'activeElement') { - Wrapper.prototype[prop] = DomApi.prototype[prop]; + Wrapper.prototype[prop] = DomApiNative.prototype[prop]; } }); @@ -416,24 +416,26 @@ if (window['ShadyDOM'] && window['ShadyDOM']['inUse'] && window['ShadyDOM']['noP } else { - forwardMethods(DomApi.prototype, [ + forwardMethods(DomApiNative.prototype, [ 'cloneNode', 'appendChild', 'insertBefore', 'removeChild', 'replaceChild', 'setAttribute', 'removeAttribute', 'querySelector', 'querySelectorAll' ]); - forwardReadOnlyProperties(DomApi.prototype, [ + forwardReadOnlyProperties(DomApiNative.prototype, [ 'parentNode', 'firstChild', 'lastChild', 'nextSibling', 'previousSibling', 'firstElementChild', 'lastElementChild', 'nextElementSibling', 'previousElementSibling', 'childNodes', 'children', 'classList' ]); - forwardProperties(DomApi.prototype, [ + forwardProperties(DomApiNative.prototype, [ 'textContent', 'innerHTML' ]); } +export const DomApi = DomApiImpl; + /** * Legacy DOM and Event manipulation API wrapper factory used to abstract * differences between native Shadow DOM and "Shady DOM" when polyfilling on @@ -445,8 +447,8 @@ if (window['ShadyDOM'] && window['ShadyDOM']['inUse'] && window['ShadyDOM']['noP * * @summary Legacy DOM and Event manipulation API wrapper factory used to * abstract differences between native Shadow DOM and "Shady DOM." - * @param {(Node|Event|DomApi|EventApi)=} obj Node or event to operate on - * @return {!DomApi|!EventApi} Wrapper providing either node API or event API + * @param {(Node|Event|DomApiNative|EventApi)=} obj Node or event to operate on + * @return {!DomApiNative|!EventApi} Wrapper providing either node API or event API */ export const dom = function(obj) { obj = obj || document; @@ -467,6 +469,3 @@ export const dom = function(obj) { } return helper; }; - -const ExportedDomApi = DomApiImpl; -export {ExportedDomApi as DomApi};