mirror of https://github.com/webpack/webpack.git
generate shorter code
This commit is contained in:
parent
7d42aa7a30
commit
1879f243dd
|
|
@ -25,7 +25,7 @@ class TrustedTypesRuntimeModule extends HelperRuntimeModule {
|
||||||
if (!trustedTypesPolicy) {
|
if (!trustedTypesPolicy) {
|
||||||
// Skip Trusted Types logic.
|
// Skip Trusted Types logic.
|
||||||
return Template.asString([
|
return Template.asString([
|
||||||
`${fn} = ${runtimeTemplate.basicFunction("url", ["return url;"])};`
|
`${fn} = ${runtimeTemplate.returningFunction("url", "url")};`
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -33,16 +33,17 @@ class TrustedTypesRuntimeModule extends HelperRuntimeModule {
|
||||||
"var policy;",
|
"var policy;",
|
||||||
`${fn} = ${runtimeTemplate.basicFunction("url", [
|
`${fn} = ${runtimeTemplate.basicFunction("url", [
|
||||||
"// Create Trusted Type policy if Trusted Types are available and the policy doesn't exist yet.",
|
"// Create Trusted Type policy if Trusted Types are available and the policy doesn't exist yet.",
|
||||||
"if (typeof policy === 'undefined') {",
|
"if (policy === undefined) {",
|
||||||
Template.indent([
|
Template.indent([
|
||||||
"policy = {",
|
"policy = {",
|
||||||
Template.indent([
|
Template.indent([
|
||||||
"createScriptURL: function(url) {",
|
`createScriptURL: ${runtimeTemplate.returningFunction(
|
||||||
Template.indent("return url;"),
|
"url",
|
||||||
"}"
|
"url"
|
||||||
|
)}`
|
||||||
]),
|
]),
|
||||||
"};",
|
"};",
|
||||||
"if (typeof trustedTypes !== 'undefined' && trustedTypes.createPolicy) {",
|
'if (typeof trustedTypes !== "undefined" && trustedTypes.createPolicy) {',
|
||||||
Template.indent([
|
Template.indent([
|
||||||
`policy = trustedTypes.createPolicy(${JSON.stringify(
|
`policy = trustedTypes.createPolicy(${JSON.stringify(
|
||||||
trustedTypesPolicy
|
trustedTypesPolicy
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue