File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed
Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -86,6 +86,7 @@ import {
8686 childElement ,
8787 childElementByTag ,
8888 childElements ,
89+ childNodes ,
8990 closest ,
9091 createElementWithAttributes ,
9192 isRTL ,
@@ -442,6 +443,15 @@ export class AmpStory extends AMP.BaseElement {
442443 // hover. (See 17654)
443444 this . element . removeAttribute ( 'title' ) ;
444445
446+ // Remove text nodes which would be shown outside of the amp-story
447+ const textNodes = childNodes (
448+ this . element ,
449+ node => node . nodeType === Node . TEXT_NODE
450+ ) ;
451+ textNodes . forEach ( node => {
452+ this . element . removeChild ( node ) ;
453+ } ) ;
454+
445455 if ( isExperimentOn ( this . win , 'amp-story-branching' ) ) {
446456 this . registerAction ( 'goToPage' , invocation => {
447457 const { args} = invocation ;
Original file line number Diff line number Diff line change @@ -183,6 +183,17 @@ describes.realWin(
183183 } ) ;
184184 } ) ;
185185
186+ it ( 'should remove text child nodes when built' , ( ) => {
187+ createPages ( story . element , 1 , [ 'cover' ] ) ;
188+ const textToRemove = 'this should be removed' ;
189+ const textNode = win . document . createTextNode ( textToRemove ) ;
190+ story . element . appendChild ( textNode ) ;
191+ story . buildCallback ( ) ;
192+ return story . layoutCallback ( ) . then ( ( ) => {
193+ expect ( story . element . innerText ) . to . not . have . string ( textToRemove ) ;
194+ } ) ;
195+ } ) ;
196+
186197 it ( 'should preload the bookend if navigating to the last page' , ( ) => {
187198 createPages ( story . element , 1 , [ 'cover' ] ) ;
188199
You can’t perform that action at this time.
0 commit comments