[@babel/standalone] Remove additional function context (#7094)
This commit is contained in:
parent
aec6e5c370
commit
1ded1d7ff6
19
packages/babel-standalone/examples/scriptTag-disabled.htm
Normal file
19
packages/babel-standalone/examples/scriptTag-disabled.htm
Normal file
@ -0,0 +1,19 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>babel-standalone example - Script tag</title>
|
||||
</head>
|
||||
<body>
|
||||
<pre id="output">This line should not be overwritten!</pre>
|
||||
|
||||
<script src="../babel.js"></script>
|
||||
<script>Babel.disableScriptTags()</script>
|
||||
<script type="text/babel">
|
||||
const doStuff = () => {
|
||||
document.getElementById('output').innerHTML = `I did an evil operation!`;
|
||||
};
|
||||
doStuff();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@ -244,14 +244,14 @@ registerPresets({
|
||||
|
||||
export const version = VERSION;
|
||||
|
||||
function onDOMContentLoaded() {
|
||||
transformScriptTags();
|
||||
}
|
||||
|
||||
// Listen for load event if we're in a browser and then kick off finding and
|
||||
// running of scripts with "text/babel" type.
|
||||
if (typeof window !== "undefined" && window && window.addEventListener) {
|
||||
window.addEventListener(
|
||||
"DOMContentLoaded",
|
||||
() => transformScriptTags(),
|
||||
false,
|
||||
);
|
||||
window.addEventListener("DOMContentLoaded", onDOMContentLoaded, false);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -266,5 +266,5 @@ export function transformScriptTags(scriptTags) {
|
||||
* Disables automatic transformation of <script> tags with "text/babel" type.
|
||||
*/
|
||||
export function disableScriptTags() {
|
||||
window.removeEventListener("DOMContentLoaded", transformScriptTags);
|
||||
window.removeEventListener("DOMContentLoaded", onDOMContentLoaded);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user