Skip to content

Commit

Permalink
Closure typing fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dfreedm committed Dec 17, 2018
1 parent a2e597c commit e4b56e4
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions lib/legacy/polymer.dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ export const matchesSelector = function(node, selector) {
* Node API wrapper class returned from `Polymer.dom.(target)` when
* `target` is a `Node`.
* @implements {PolymerDomApi}
* @unrestricted
*/
export let DomApi = class {
class DomApi {

/**
* @param {Node} node Node for which to create a Polymer.dom helper object.
Expand Down Expand Up @@ -377,10 +378,14 @@ DomApi.prototype.textContent;
/** @type {string} */
DomApi.prototype.innerHTML;

let DomApiImpl = DomApi;

if (window['ShadyDOM'] && window['ShadyDOM']['inUse'] && window['ShadyDOM']['noPatch'] && window['ShadyDOM']['Wrapper']) {

/** @private */
/**
* @private
* @extends {HTMLElement}
*/
class Wrapper extends window['ShadyDOM']['Wrapper'] {}

// copy bespoke API onto wrapper
Expand All @@ -390,7 +395,7 @@ if (window['ShadyDOM'] && window['ShadyDOM']['inUse'] && window['ShadyDOM']['noP
}
});

DomApi = Wrapper;
DomApiImpl = Wrapper;

Object.defineProperties(EventApi.prototype, {

Expand Down Expand Up @@ -429,6 +434,8 @@ if (window['ShadyDOM'] && window['ShadyDOM']['inUse'] && window['ShadyDOM']['noP
]);
}

export {DomApiImpl as DomApi};

/**
* Legacy DOM and Event manipulation API wrapper factory used to abstract
* differences between native Shadow DOM and "Shady DOM" when polyfilling on
Expand All @@ -440,20 +447,23 @@ 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)=} obj Node or event to operate on
* @param {(Node|Event|DomApi|EventApi)=} obj Node or event to operate on
* @return {!DomApi|!EventApi} Wrapper providing either node API or event API
*/
export const dom = function(obj) {
obj = obj || document;
if (obj instanceof DomApi || obj instanceof EventApi) {
return obj;
if (obj instanceof DomApiImpl) {
return /** @type {!DomApi} */(obj);
}
if (obj instanceof EventApi) {
return /** @type {!EventApi} */(obj);
}
let helper = obj['__domApi'];
if (!helper) {
if (obj instanceof Event) {
helper = new EventApi(obj);
} else {
helper = new DomApi(obj);
helper = new DomApi(/** @type {Node} */(obj));
}
obj['__domApi'] = helper;
}
Expand Down

0 comments on commit e4b56e4

Please sign in to comment.