main
Last change
on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago |
F4 Finalna Verzija
|
-
Property mode
set to
100644
|
File size:
952 bytes
|
Line | |
---|
1 | /*
|
---|
2 | MIT License http://www.opensource.org/licenses/mit-license.php
|
---|
3 | */
|
---|
4 |
|
---|
5 | "use strict";
|
---|
6 |
|
---|
7 | const RuntimeGlobals = require("../RuntimeGlobals");
|
---|
8 | const Template = require("../Template");
|
---|
9 | const HelperRuntimeModule = require("./HelperRuntimeModule");
|
---|
10 |
|
---|
11 | /** @typedef {import("../Compilation")} Compilation */
|
---|
12 |
|
---|
13 | class CreateScriptRuntimeModule extends HelperRuntimeModule {
|
---|
14 | constructor() {
|
---|
15 | super("trusted types script");
|
---|
16 | }
|
---|
17 |
|
---|
18 | /**
|
---|
19 | * @returns {string | null} runtime code
|
---|
20 | */
|
---|
21 | generate() {
|
---|
22 | const compilation = /** @type {Compilation} */ (this.compilation);
|
---|
23 | const { runtimeTemplate, outputOptions } = compilation;
|
---|
24 | const { trustedTypes } = outputOptions;
|
---|
25 | const fn = RuntimeGlobals.createScript;
|
---|
26 |
|
---|
27 | return Template.asString(
|
---|
28 | `${fn} = ${runtimeTemplate.returningFunction(
|
---|
29 | trustedTypes
|
---|
30 | ? `${RuntimeGlobals.getTrustedTypesPolicy}().createScript(script)`
|
---|
31 | : "script",
|
---|
32 | "script"
|
---|
33 | )};`
|
---|
34 | );
|
---|
35 | }
|
---|
36 | }
|
---|
37 |
|
---|
38 | module.exports = CreateScriptRuntimeModule;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.