/* MIT License http://www.opensource.org/licenses/mit-license.php */ "use strict"; const { HTML_TYPE } = require("../ModuleSourceTypeConstants"); const makeSerializable = require("../util/makeSerializable"); const ModuleDependency = require("./ModuleDependency"); /** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */ /** @typedef {import("../CodeGenerationResults")} CodeGenerationResults */ /** @typedef {import("../Dependency").UpdateHashContext} UpdateHashContext */ /** @typedef {import("../Dependency")} Dependency */ /** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */ /** @typedef {import("../Module")} Module */ /** @typedef {import("../javascript/JavascriptParser").Range} Range */ /** @typedef {import("../util/Hash")} Hash */ // One pass over the source: each char is replaced once and replacements aren't // re-scanned, so this matches the `&`-first sequential escape chain exactly. const ATTR_ESCAPE_REGEXP = /[&"']/g; /** @type {Record} */ const ATTR_ESCAPES = { "&": "&", '"': """, "'": "'" }; /** * @param {string} c matched character * @returns {string} the HTML-attribute-escaped entity */ const escapeAttrChar = (c) => ATTR_ESCAPES[c]; /** * Represents an `