1
0
mirror of https://github.com/jaandrle/deka-dom-el synced 2024-11-25 09:49:36 +01:00
deka-dom-el/docs_src/components/examples/elements/dekaAssign.js

34 lines
933 B
JavaScript
Raw Normal View History

2023-11-21 14:37:57 +01:00
import { assign, assignAttribute, classListDeclarative } from "deka-dom-el";
2023-11-06 13:45:43 +01:00
const paragraph= document.createElement("p");
assignAttribute(paragraph, "textContent", "Hello, world!");
2023-11-21 14:37:57 +01:00
assignAttribute(paragraph, "style", "color: red; font-weight: bold;");
2023-11-06 13:45:43 +01:00
assignAttribute(paragraph, "style", { color: "navy" });
assignAttribute(paragraph, "dataTest1", "v1");
assignAttribute(paragraph, "dataset", { test2: "v2" });
2023-11-21 14:37:57 +01:00
assign(paragraph, { //textContent and style see above
ariaLabel: "v1", //data* see above
ariaset: { role: "none" }, // dataset see above
"=onclick": "console.log(event)",
onmouseout: console.info,
".something": "something",
classList: {} //see below
});
2023-11-06 13:45:43 +01:00
classListDeclarative(paragraph, {
classAdd: true,
classRemove: false,
classAdd1: 1,
classRemove1: 0,
classToggle: -1
});
console.log(paragraph.outerHTML);
2023-11-21 14:37:57 +01:00
console.log("paragraph.something=", paragraph.something);
2023-11-06 13:45:43 +01:00
document.body.append(
paragraph
);