You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After having a look through the code and doing some debugging, I found what the cause of the issue is, but I'm not really sure of what a best solution would be for this case.
At the end of lib/replace.js, the contents of the modified file which has just been parsed through domino are written into the file:
// write out newly created file contentsgrunt.file.write(file,getDoctype(document)+document.documentElement.outerHTML);
The problem is that when the code goes into domino, it's properly being parsed as a DOM tree, and in our original code there are actually 3 different start tags for . Apparently, domino uses the last one as the actual start of the node, and that's what it outputs when we get the outerHTML of the document.documentElement, which in a way, makes complete sense.
The innerHTML of document does have the whole thing, but without newlines around those comments, and it does still contain the doctype:
I don't think it would be desirable to output the HTML like this from the plugin, so I thought it was probably better to have some brain storming around a potential better fix for this.
The text was updated successfully, but these errors were encountered:
Following up from the discussion on Twitter, here's a better description of the problem and what I've found out about it.
In this specific case, the HTML file has something like this:
After passing through grunt-requirejs with the replaceRequireScript option turned on, we end up with the following:
After having a look through the code and doing some debugging, I found what the cause of the issue is, but I'm not really sure of what a best solution would be for this case.
At the end of lib/replace.js, the contents of the modified file which has just been parsed through domino are written into the file:
The problem is that when the code goes into domino, it's properly being parsed as a DOM tree, and in our original code there are actually 3 different start tags for . Apparently, domino uses the last one as the actual start of the node, and that's what it outputs when we get the outerHTML of the document.documentElement, which in a way, makes complete sense.
The innerHTML of document does have the whole thing, but without newlines around those comments, and it does still contain the doctype:
I don't think it would be desirable to output the HTML like this from the plugin, so I thought it was probably better to have some brain storming around a potential better fix for this.
The text was updated successfully, but these errors were encountered: