-
Notifications
You must be signed in to change notification settings - Fork 638
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: improve serialization across multiple writes
- Loading branch information
1 parent
7526081
commit 2b09f86
Showing
35 changed files
with
336 additions
and
228 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
packages/marko/src/core-tags/components/add-preferred-script-location-transformer.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
"use strict"; | ||
|
||
module.exports = function transform(el, context) { | ||
if (context.outputType === "html" && !context.___hasPreferredScriptLocation) { | ||
context.___hasPreferredScriptLocation = true; | ||
el.parentNode.appendChild( | ||
context.createNodeForEl("_preferred-script-location") | ||
); | ||
} | ||
}; |
14 changes: 4 additions & 10 deletions
14
packages/marko/src/core-tags/components/body-transformer.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,8 @@ | ||
"use strict"; | ||
|
||
module.exports = function transform(el, context) { | ||
let componentGlobalsNode = context.createNodeForEl("component-globals"); | ||
el.prependChild(componentGlobalsNode); | ||
|
||
let initComponentsNode = context.createNodeForEl("init-components"); | ||
el.appendChild(initComponentsNode); | ||
|
||
// Make <await-reorderer> optional. Automatically insert it before the | ||
// body tag. | ||
let awaitReorderer = context.createNodeForEl("await-reorderer"); | ||
el.appendChild(awaitReorderer); | ||
if (context.outputType === "html") { | ||
el.appendChild(context.createNodeForEl("init-components")); | ||
el.appendChild(context.createNodeForEl("await-reorderer")); | ||
} | ||
}; |
2 changes: 0 additions & 2 deletions
2
packages/marko/src/core-tags/components/component-globals-tag-browser.js
This file was deleted.
Oops, something went wrong.
45 changes: 0 additions & 45 deletions
45
packages/marko/src/core-tags/components/component-globals-tag.js
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
packages/marko/src/core-tags/components/preferred-script-location-tag.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
"use strict"; | ||
|
||
function forceScriptTagAtThisPoint(out) { | ||
out.global.___isLastFlush = true; | ||
|
||
const writer = out.writer; | ||
const htmlSoFar = writer.toString(); | ||
|
||
writer.clear(); | ||
writer.write(htmlSoFar); | ||
|
||
out.global.___isLastFlush = undefined; | ||
} | ||
|
||
module.exports = function render(input, out) { | ||
if (out.isSync() === true) { | ||
forceScriptTagAtThisPoint(out); | ||
} else { | ||
if (out.global.___clientReorderContext) { | ||
out.flush(); | ||
} | ||
|
||
const asyncOut = out.beginAsync({ last: true, timeout: -1 }); | ||
out.onLast(function(next) { | ||
forceScriptTagAtThisPoint(asyncOut); | ||
asyncOut.end(); | ||
next(); | ||
}); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
packages/marko/src/core-tags/migrate/component-globals-tag.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module.exports = function render(elNode, context) { | ||
context.deprecate( | ||
"The <component-globals> tag is deprecated. This functionality has been added to the '<init-components>' tag, you can safely remove the '<component-globals>' tag." | ||
); | ||
|
||
elNode.detach(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.