This repository was archived by the owner on Mar 13, 2018. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1111 var Node = scope . wrappers . Node ;
1212 var ShadowRoot = scope . wrappers . ShadowRoot ;
1313 var assert = scope . assert ;
14- var getHostForShadowRoot = scope . getHostForShadowRoot ;
1514 var mixin = scope . mixin ;
1615 var muteMutationEvents = scope . muteMutationEvents ;
1716 var oneOf = scope . oneOf ;
253252 }
254253
255254 function getRendererForShadowRoot ( shadowRoot ) {
256- return getRendererForHost ( getHostForShadowRoot ( shadowRoot ) ) ;
255+ return getRendererForHost ( shadowRoot . host ) ;
257256 }
258257
259258 var spliceDiff = new ArraySplice ( ) ;
Original file line number Diff line number Diff line change 4343 return nextOlderShadowTreeTable . get ( this ) || null ;
4444 } ,
4545
46+ get host ( ) {
47+ return shadowHostTable . get ( this ) || null ;
48+ } ,
49+
4650 invalidateShadowRenderer : function ( ) {
4751 return shadowHostTable . get ( this ) . invalidateShadowRenderer ( ) ;
4852 } ,
5761 } ) ;
5862
5963 scope . wrappers . ShadowRoot = ShadowRoot ;
60- scope . getHostForShadowRoot = function ( node ) {
61- return shadowHostTable . get ( node ) ;
62- } ;
6364} ) ( this . ShadowDOMPolyfill ) ;
Original file line number Diff line number Diff line change 4949
5050 // 1.
5151 if ( isShadowRoot ( node ) )
52- return getInsertionParent ( node ) || scope . getHostForShadowRoot ( node ) ;
52+ return getInsertionParent ( node ) || node . host ;
5353
5454 // 2.
5555 var eventParents = scope . eventParentsTable . get ( node ) ;
145145 ancestor = calculateParents ( ancestor , context , ancestors ) ; // 3.4.7.
146146 }
147147 if ( isShadowRoot ( target ) ) // 3.5.
148- target = scope . getHostForShadowRoot ( target ) ;
148+ target = target . host ;
149149 else
150150 target = target . parentNode ; // 3.6.
151151 }
174174 function enclosedBy ( a , b ) {
175175 if ( a === b )
176176 return true ;
177- if ( a instanceof wrappers . ShadowRoot ) {
178- var host = scope . getHostForShadowRoot ( a ) ;
179- return enclosedBy ( rootOfNode ( host ) , b ) ;
180- }
177+ if ( a instanceof wrappers . ShadowRoot )
178+ return enclosedBy ( rootOfNode ( a . host ) , b ) ;
181179 return false ;
182180 }
183181
599597
600598 function getTargetToListenAt ( wrapper ) {
601599 if ( wrapper instanceof wrappers . ShadowRoot )
602- wrapper = scope . getHostForShadowRoot ( wrapper ) ;
600+ wrapper = wrapper . host ;
603601 return unwrap ( wrapper ) ;
604602 }
605603
Original file line number Diff line number Diff line change @@ -56,4 +56,13 @@ suite('ShadowRoot', function() {
5656 assert . equal ( sr2 . olderShadowRoot , sr ) ;
5757 } ) ;
5858
59+ test ( 'host' , function ( ) {
60+ var host = document . createElement ( 'div' ) ;
61+ var sr = host . createShadowRoot ( ) ;
62+ assert . equal ( host , sr . host ) ;
63+
64+ var sr2 = host . createShadowRoot ( ) ;
65+ assert . equal ( host , sr2 . host ) ;
66+ } ) ;
67+
5968} ) ;
You can’t perform that action at this time.
0 commit comments