|
Last change
on this file since 9af201e was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
1004 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 | * Generates runtime code for this runtime module.
|
|---|
| 20 | * @returns {string | null} runtime code
|
|---|
| 21 | */
|
|---|
| 22 | generate() {
|
|---|
| 23 | const compilation = /** @type {Compilation} */ (this.compilation);
|
|---|
| 24 | const { runtimeTemplate, outputOptions } = compilation;
|
|---|
| 25 | const { trustedTypes } = outputOptions;
|
|---|
| 26 | const fn = RuntimeGlobals.createScript;
|
|---|
| 27 |
|
|---|
| 28 | return Template.asString(
|
|---|
| 29 | `${fn} = ${runtimeTemplate.returningFunction(
|
|---|
| 30 | trustedTypes
|
|---|
| 31 | ? `${RuntimeGlobals.getTrustedTypesPolicy}().createScript(script)`
|
|---|
| 32 | : "script",
|
|---|
| 33 | "script"
|
|---|
| 34 | )};`
|
|---|
| 35 | );
|
|---|
| 36 | }
|
|---|
| 37 | }
|
|---|
| 38 |
|
|---|
| 39 | module.exports = CreateScriptRuntimeModule;
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.