Skip to content

Commit e4b56e4

Browse files
committed
Closure typing fixes
1 parent a2e597c commit e4b56e4

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

lib/legacy/polymer.dom.js

+17-7
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@ export const matchesSelector = function(node, selector) {
4040
* Node API wrapper class returned from `Polymer.dom.(target)` when
4141
* `target` is a `Node`.
4242
* @implements {PolymerDomApi}
43+
* @unrestricted
4344
*/
44-
export let DomApi = class {
45+
class DomApi {
4546

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

381+
let DomApiImpl = DomApi;
380382

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

383-
/** @private */
385+
/**
386+
* @private
387+
* @extends {HTMLElement}
388+
*/
384389
class Wrapper extends window['ShadyDOM']['Wrapper'] {}
385390

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

393-
DomApi = Wrapper;
398+
DomApiImpl = Wrapper;
394399

395400
Object.defineProperties(EventApi.prototype, {
396401

@@ -429,6 +434,8 @@ if (window['ShadyDOM'] && window['ShadyDOM']['inUse'] && window['ShadyDOM']['noP
429434
]);
430435
}
431436

437+
export {DomApiImpl as DomApi};
438+
432439
/**
433440
* Legacy DOM and Event manipulation API wrapper factory used to abstract
434441
* differences between native Shadow DOM and "Shady DOM" when polyfilling on
@@ -440,20 +447,23 @@ if (window['ShadyDOM'] && window['ShadyDOM']['inUse'] && window['ShadyDOM']['noP
440447
*
441448
* @summary Legacy DOM and Event manipulation API wrapper factory used to
442449
* abstract differences between native Shadow DOM and "Shady DOM."
443-
* @param {(Node|Event)=} obj Node or event to operate on
450+
* @param {(Node|Event|DomApi|EventApi)=} obj Node or event to operate on
444451
* @return {!DomApi|!EventApi} Wrapper providing either node API or event API
445452
*/
446453
export const dom = function(obj) {
447454
obj = obj || document;
448-
if (obj instanceof DomApi || obj instanceof EventApi) {
449-
return obj;
455+
if (obj instanceof DomApiImpl) {
456+
return /** @type {!DomApi} */(obj);
457+
}
458+
if (obj instanceof EventApi) {
459+
return /** @type {!EventApi} */(obj);
450460
}
451461
let helper = obj['__domApi'];
452462
if (!helper) {
453463
if (obj instanceof Event) {
454464
helper = new EventApi(obj);
455465
} else {
456-
helper = new DomApi(obj);
466+
helper = new DomApi(/** @type {Node} */(obj));
457467
}
458468
obj['__domApi'] = helper;
459469
}

0 commit comments

Comments
 (0)