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) {
|
||||
// Skip Trusted Types logic.
|
||||
return Template.asString([
|
||||
`${fn} = ${runtimeTemplate.basicFunction("url", ["return url;"])};`
|
||||
`${fn} = ${runtimeTemplate.returningFunction("url", "url")};`
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
@ -33,16 +33,17 @@ class TrustedTypesRuntimeModule extends HelperRuntimeModule {
|
|||
"var policy;",
|
||||
`${fn} = ${runtimeTemplate.basicFunction("url", [
|
||||
"// 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([
|
||||
"policy = {",
|
||||
Template.indent([
|
||||
"createScriptURL: function(url) {",
|
||||
Template.indent("return url;"),
|
||||
"}"
|
||||
`createScriptURL: ${runtimeTemplate.returningFunction(
|
||||
"url",
|
||||
"url"
|
||||
)}`
|
||||
]),
|
||||
"};",
|
||||
"if (typeof trustedTypes !== 'undefined' && trustedTypes.createPolicy) {",
|
||||
'if (typeof trustedTypes !== "undefined" && trustedTypes.createPolicy) {',
|
||||
Template.indent([
|
||||
`policy = trustedTypes.createPolicy(${JSON.stringify(
|
||||
trustedTypesPolicy
|
||||
|
|
|
|||
Loading…
Reference in New Issue