Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
!/test/client
coverage
node_modules
examples/client/trusted-types-overlay/app.js
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
coverage
node_modules
CHANGELOG.md
examples/client/trusted-types-overlay/app.js
4 changes: 3 additions & 1 deletion client-src/overlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,9 @@ const createOverlay = (options) => {
*/
function ensureOverlayExists(callback, trustedTypesPolicyName) {
if (containerElement) {
containerElement.innerHTML = "";
containerElement.innerHTML = overlayTrustedTypesPolicy
? overlayTrustedTypesPolicy.createHTML("")
: "";
// Everything is ready, call the callback right away.
callback(containerElement);

Expand Down
3 changes: 3 additions & 0 deletions examples/client/trusted-types-overlay/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ const target = document.querySelector("#target");

target.classList.add("pass");
target.textContent = "Success!";

// To display an overlay with an error
(
5 changes: 4 additions & 1 deletion examples/client/trusted-types-overlay/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@ const { setup } = require("../../util");
const config = setup({
context: __dirname,
// create error for overlay
entry: "./invalid.js",
entry: "./app.js",
output: {
trustedTypes: { policyName: "webpack" },
},
devServer: {
headers: {
"Content-Security-Policy": "require-trusted-types-for 'script'",
},
client: {
overlay: {
trustedTypesPolicyName: "webpack#dev-overlay",
Expand Down
Loading