1
0
mirror of https://github.com/jaandrle/deka-dom-el synced 2024-11-25 01:39:37 +01:00

🐛 add missing cases for href, src, class, xlink:href, textContent, innerText

This commit is contained in:
Jan Andrle 2023-09-21 13:14:55 +02:00
parent 951f589ceb
commit 0794659104
Signed by: jaandrle
GPG Key ID: B3A25AED155AFFAB
5 changed files with 26 additions and 6 deletions

View File

@ -90,6 +90,7 @@
if (typeof a == "object" && a !== null && !Array.isArray(a)) if (typeof a == "object" && a !== null && !Array.isArray(a))
switch (s) { switch (s) {
case "style": case "style":
case "dataset":
return N(r, a, T.bind(null, e[s])); return N(r, a, T.bind(null, e[s]));
case "ariaset": case "ariaset":
return N(r, a, (E, c) => i("aria-" + E, c)); return N(r, a, (E, c) => i("aria-" + E, c));
@ -102,8 +103,12 @@
return s = s.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase(), i(s, a); return s = s.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase(), i(s, a);
switch (s === "className" && (s = "class"), s) { switch (s === "className" && (s = "class"), s) {
case "href": case "href":
case "src":
case "class":
case "xlink:href":
return i(s, a, "http://www.w3.org/1999/xlink"); return i(s, a, "http://www.w3.org/1999/xlink");
case "textContent": case "textContent":
case "innerText":
return o ? e.appendChild(document.createTextNode(a)) : j(e, s, a); return o ? e.appendChild(document.createTextNode(a)) : j(e, s, a);
} }
return H(e, s) ? j(e, s, a) : i(s, a); return H(e, s) ? j(e, s, a) : i(s, a);

5
dist/dde.js vendored
View File

@ -86,6 +86,7 @@
if (typeof u == "object" && u !== null && !Array.isArray(u)) if (typeof u == "object" && u !== null && !Array.isArray(u))
switch (f) { switch (f) {
case "style": case "style":
case "dataset":
return O(n, u, D.bind(null, e[f])); return O(n, u, D.bind(null, e[f]));
case "ariaset": case "ariaset":
return O(n, u, (E, o) => d("aria-" + E, o)); return O(n, u, (E, o) => d("aria-" + E, o));
@ -98,8 +99,12 @@
return f = f.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase(), d(f, u); return f = f.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase(), d(f, u);
switch (f === "className" && (f = "class"), f) { switch (f === "className" && (f = "class"), f) {
case "href": case "href":
case "src":
case "class":
case "xlink:href":
return d(f, u, "http://www.w3.org/1999/xlink"); return d(f, u, "http://www.w3.org/1999/xlink");
case "textContent": case "textContent":
case "innerText":
return c ? e.appendChild(document.createTextNode(u)) : R(e, f, u); return c ? e.appendChild(document.createTextNode(u)) : R(e, f, u);
} }
return _(e, f) ? R(e, f, u) : d(f, u); return _(e, f) ? R(e, f, u) : d(f, u);

View File

@ -88,6 +88,7 @@ function w(e, ...t) {
if (typeof a == "object" && a !== null && !Array.isArray(a)) if (typeof a == "object" && a !== null && !Array.isArray(a))
switch (s) { switch (s) {
case "style": case "style":
case "dataset":
return N(r, a, T.bind(null, e[s])); return N(r, a, T.bind(null, e[s]));
case "ariaset": case "ariaset":
return N(r, a, (E, c) => i("aria-" + E, c)); return N(r, a, (E, c) => i("aria-" + E, c));
@ -100,8 +101,12 @@ function w(e, ...t) {
return s = s.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase(), i(s, a); return s = s.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase(), i(s, a);
switch (s === "className" && (s = "class"), s) { switch (s === "className" && (s = "class"), s) {
case "href": case "href":
case "src":
case "class":
case "xlink:href":
return i(s, a, "http://www.w3.org/1999/xlink"); return i(s, a, "http://www.w3.org/1999/xlink");
case "textContent": case "textContent":
case "innerText":
return o ? e.appendChild(document.createTextNode(a)) : j(e, s, a); return o ? e.appendChild(document.createTextNode(a)) : j(e, s, a);
} }
return H(e, s) ? j(e, s, a) : i(s, a); return H(e, s) ? j(e, s, a) : i(s, a);

5
dist/esm.js vendored
View File

@ -84,6 +84,7 @@ function x(e, ...t) {
if (typeof u == "object" && u !== null && !Array.isArray(u)) if (typeof u == "object" && u !== null && !Array.isArray(u))
switch (f) { switch (f) {
case "style": case "style":
case "dataset":
return O(n, u, D.bind(null, e[f])); return O(n, u, D.bind(null, e[f]));
case "ariaset": case "ariaset":
return O(n, u, (E, o) => d("aria-" + E, o)); return O(n, u, (E, o) => d("aria-" + E, o));
@ -96,8 +97,12 @@ function x(e, ...t) {
return f = f.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase(), d(f, u); return f = f.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase(), d(f, u);
switch (f === "className" && (f = "class"), f) { switch (f === "className" && (f = "class"), f) {
case "href": case "href":
case "src":
case "class":
case "xlink:href":
return d(f, u, "http://www.w3.org/1999/xlink"); return d(f, u, "http://www.w3.org/1999/xlink");
case "textContent": case "textContent":
case "innerText":
return c ? e.appendChild(document.createTextNode(u)) : R(e, f, u); return c ? e.appendChild(document.createTextNode(u)) : R(e, f, u);
} }
return _(e, f) ? R(e, f, u) : d(f, u); return _(e, f) ? R(e, f, u) : d(f, u);

View File

@ -52,10 +52,10 @@ export function assign(element, ...attributes){
if("."===k) return setDelete(element, key.slice(1), attr); if("."===k) return setDelete(element, key.slice(1), attr);
if(typeof attr === "object" && attr!==null && !Array.isArray(attr)){ if(typeof attr === "object" && attr!==null && !Array.isArray(attr)){
switch(key){ switch(key){
case "style" || "dataset": return forEachEntries(s, attr, setDelete.bind(null, element[key])); case "style": case "dataset": return forEachEntries(s, attr, setDelete.bind(null, element[key]));
case "ariaset": return forEachEntries(s, attr, (key, val)=> setRemoveAttr("aria-"+key, val)); case "ariaset": return forEachEntries(s, attr, (key, val)=> setRemoveAttr("aria-"+key, val));
case "classList": return classListDeclarative.call(_this, element, attr); case "classList": return classListDeclarative.call(_this, element, attr);
default: return Reflect.set(element, key, attr); default: return Reflect.set(element, key, attr);
} }
} }
if(/(aria|data)([A-Z])/.test(key)){ if(/(aria|data)([A-Z])/.test(key)){
@ -64,9 +64,9 @@ export function assign(element, ...attributes){
} }
if("className"===key) key= "class"; if("className"===key) key= "class";
switch(key){ switch(key){
case "href" || "src" || "class" || "xlink:href": case "href": case "src": case "class": case "xlink:href":
return setRemoveAttr(key, attr, "http://www.w3.org/1999/xlink"); return setRemoveAttr(key, attr, "http://www.w3.org/1999/xlink");
case "textContent" || "innerText": case "textContent": case "innerText":
if(!is_svg) return setDeleteAttr(element, key, attr); if(!is_svg) return setDeleteAttr(element, key, attr);
return element.appendChild(document.createTextNode(attr)); return element.appendChild(document.createTextNode(attr));
} }