MCPcopy
hub / github.com/mdn/web-components-examples / updateStyle

Function updateStyle

life-cycle-callbacks/main.js:42–51  ·  view source on GitHub ↗
(elem)

Source from the content-addressed store, hash-verified

40customElements.define("custom-square", Square);
41
42function updateStyle(elem) {
43 const shadow = elem.shadowRoot;
44 shadow.querySelector("style").textContent = `
45 div {
46 width: ${elem.getAttribute("size")}px;
47 height: ${elem.getAttribute("size")}px;
48 background-color: ${elem.getAttribute("color")};
49 }
50 `;
51}
52
53const add = document.querySelector(".add");
54const update = document.querySelector(".update");

Callers 2

connectedCallbackMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected