@@ -26,16 +26,10 @@ module.exports = class BasePageWriter extends Filter {
2626 let dom = new JSDOM ( content ) ;
2727 let scriptTags = dom . window . document . querySelectorAll ( 'script' ) ;
2828
29- // In fastboot-config.js the paths are transformed with stripLeadingSlash
30- // do we need to concat rootURL here?
31- let rootURL = this . _rootURL ;
32-
33- ignoreUnexpectedScripts ( scriptTags , this . _expectedFiles ) ;
29+ this . _ignoreUnexpectedScripts ( scriptTags ) ;
3430
3531 let fastbootScripts = this . _findFastbootScriptToInsert ( scriptTags ) ;
36-
37- let appJsTag = findAppJsTag ( scriptTags , this . _appJsPath , rootURL ) ;
38-
32+ let appJsTag = findAppJsTag ( scriptTags , this . _appJsPath , this . _rootURL ) ;
3933 insertFastbootScriptsBeforeAppJsTags ( fastbootScripts , appJsTag ) ;
4034
4135 return dom . serialize ( ) ;
@@ -53,6 +47,16 @@ module.exports = class BasePageWriter extends Filter {
5347 . map ( src => urlWithin ( src , rootURL ) )
5448 . filter ( src => ! scriptSrcs . includes ( src ) ) ;
5549 }
50+
51+ _ignoreUnexpectedScripts ( scriptTags ) {
52+ let expectedFiles = this . _expectedFiles ;
53+ let rootURL = this . _rootURL ;
54+ for ( let element of scriptTags ) {
55+ if ( ! expectedFiles . includes ( urlWithin ( element . getAttribute ( 'src' ) , rootURL ) ) ) {
56+ element . setAttribute ( 'data-fastboot-ignore' , '' ) ;
57+ }
58+ }
59+ }
5660} ;
5761
5862function expectedFiles ( outputPaths ) {
@@ -66,14 +70,6 @@ function expectedFiles(outputPaths) {
6670 return [ appFilePath , appFastbootFilePath , vendorFilePath ] ;
6771}
6872
69- function ignoreUnexpectedScripts ( scriptTags , expectedFiles ) {
70- for ( let element of scriptTags ) {
71- if ( ! expectedFiles . includes ( urlWithin ( element . getAttribute ( 'src' ) ) ) ) {
72- element . setAttribute ( 'data-fastboot-ignore' , '' ) ;
73- }
74- }
75- }
76-
7773function getRootURL ( appName , config ) {
7874 let rootURL = ( config [ appName ] && config [ appName ] . rootURL ) || '/' ;
7975 if ( ! rootURL . endsWith ( '/' ) ) {
@@ -118,6 +114,7 @@ class NodeRange {
118114 let newTag = this . end . ownerDocument . createElement ( 'fastboot-script' ) ;
119115 newTag . setAttribute ( 'src' , src ) ;
120116 this . insertNode ( newTag ) ;
117+ this . insertNode ( this . end . ownerDocument . createTextNode ( '\n' ) ) ;
121118 }
122119
123120 insertNode ( node ) {
0 commit comments