MCPcopy Index your code
hub / github.com/webpack/webpack-dev-server / createContainer

Function createContainer

client-src/overlay.js:475–544  ·  view source on GitHub ↗

* @param {string | false | undefined} trustedTypesPolicyName trusted types police name

(trustedTypesPolicyName)

Source from the content-addressed store, hash-verified

473 * @param {string | false | undefined} trustedTypesPolicyName trusted types police name
474 */
475 function createContainer(trustedTypesPolicyName) {
476 // Enable Trusted Types if they are available in the current browser.
477 if (window.trustedTypes) {
478 overlayTrustedTypesPolicy = window.trustedTypes.createPolicy(
479 trustedTypesPolicyName || "webpack-dev-server#overlay",
480 {
481 createHTML: (value) => value,
482 },
483 );
484 }
485
486 iframeContainerElement = document.createElement("iframe");
487 iframeContainerElement.id = "webpack-dev-server-client-overlay";
488 iframeContainerElement.src = "about:blank";
489 applyStyle(iframeContainerElement, iframeStyle);
490
491 iframeContainerElement.onload = () => {
492 const contentElement =
493 /** @type {Document} */
494 (
495 /** @type {HTMLIFrameElement} */
496 (iframeContainerElement).contentDocument
497 ).createElement("div");
498 containerElement =
499 /** @type {Document} */
500 (
501 /** @type {HTMLIFrameElement} */
502 (iframeContainerElement).contentDocument
503 ).createElement("div");
504
505 contentElement.id = "webpack-dev-server-client-overlay-div";
506 applyStyle(contentElement, containerStyle);
507
508 headerElement = document.createElement("div");
509
510 headerElement.innerText = "Compiled with problems:";
511 applyStyle(headerElement, headerStyle);
512
513 const closeButtonElement = document.createElement("button");
514
515 applyStyle(closeButtonElement, dismissButtonStyle);
516
517 closeButtonElement.innerText = "×";
518 closeButtonElement.ariaLabel = "Dismiss";
519 closeButtonElement.addEventListener("click", () => {
520 // eslint-disable-next-line no-use-before-define
521 overlayService.send({ type: "DISMISS" });
522 });
523
524 contentElement.appendChild(headerElement);
525 contentElement.appendChild(closeButtonElement);
526 contentElement.appendChild(containerElement);
527
528 /** @type {Document} */
529 (
530 /** @type {HTMLIFrameElement} */
531 (iframeContainerElement).contentDocument
532 ).body.appendChild(contentElement);

Callers 1

ensureOverlayExistsFunction · 0.85

Calls 1

applyStyleFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…