@@ -40,8 +40,9 @@ export const matchesSelector = function(node, selector) {
40
40
* Node API wrapper class returned from `Polymer.dom.(target)` when
41
41
* `target` is a `Node`.
42
42
* @implements {PolymerDomApi}
43
+ * @unrestricted
43
44
*/
44
- export let DomApi = class {
45
+ class DomApi {
45
46
46
47
/**
47
48
* @param {Node } node Node for which to create a Polymer.dom helper object.
@@ -377,10 +378,14 @@ DomApi.prototype.textContent;
377
378
/** @type {string } */
378
379
DomApi . prototype . innerHTML ;
379
380
381
+ let DomApiImpl = DomApi ;
380
382
381
383
if ( window [ 'ShadyDOM' ] && window [ 'ShadyDOM' ] [ 'inUse' ] && window [ 'ShadyDOM' ] [ 'noPatch' ] && window [ 'ShadyDOM' ] [ 'Wrapper' ] ) {
382
384
383
- /** @private */
385
+ /**
386
+ * @private
387
+ * @extends {HTMLElement }
388
+ */
384
389
class Wrapper extends window [ 'ShadyDOM' ] [ 'Wrapper' ] { }
385
390
386
391
// copy bespoke API onto wrapper
@@ -390,7 +395,7 @@ if (window['ShadyDOM'] && window['ShadyDOM']['inUse'] && window['ShadyDOM']['noP
390
395
}
391
396
} ) ;
392
397
393
- DomApi = Wrapper ;
398
+ DomApiImpl = Wrapper ;
394
399
395
400
Object . defineProperties ( EventApi . prototype , {
396
401
@@ -429,6 +434,8 @@ if (window['ShadyDOM'] && window['ShadyDOM']['inUse'] && window['ShadyDOM']['noP
429
434
] ) ;
430
435
}
431
436
437
+ export { DomApiImpl as DomApi } ;
438
+
432
439
/**
433
440
* Legacy DOM and Event manipulation API wrapper factory used to abstract
434
441
* differences between native Shadow DOM and "Shady DOM" when polyfilling on
@@ -440,20 +447,23 @@ if (window['ShadyDOM'] && window['ShadyDOM']['inUse'] && window['ShadyDOM']['noP
440
447
*
441
448
* @summary Legacy DOM and Event manipulation API wrapper factory used to
442
449
* 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
444
451
* @return {!DomApi|!EventApi } Wrapper providing either node API or event API
445
452
*/
446
453
export const dom = function ( obj ) {
447
454
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 ) ;
450
460
}
451
461
let helper = obj [ '__domApi' ] ;
452
462
if ( ! helper ) {
453
463
if ( obj instanceof Event ) {
454
464
helper = new EventApi ( obj ) ;
455
465
} else {
456
- helper = new DomApi ( obj ) ;
466
+ helper = new DomApi ( /** @type { Node } */ ( obj ) ) ;
457
467
}
458
468
obj [ '__domApi' ] = helper ;
459
469
}
0 commit comments