Skip to content

Commit ce6c03b

Browse files
committed
fix: enhance setAttribute function to respect form-attributes and streamline attribute setting
1 parent 2b4aecb commit ce6c03b

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

src/form.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,15 @@ const formAttributesSelector = formAttributes.map((attr) => `[${attr}]`).join(",
7171
*/
7272
function setAttribute(form, elements) {
7373
if (!elements) elements = form.querySelectorAll(formAttributesSelector);
74-
75-
for (let attribute of form.attributes) {
76-
if (!formAttributes.includes(attribute.name)) continue;
77-
78-
for (let el of elements) {
74+
for (let el of elements) {
75+
if (el.getAttribute("form-attributes") === "false") continue;
76+
for (let attribute of form.attributes) {
77+
if (!formAttributes.includes(attribute.name)) continue;
78+
// let elArray = el.getAttribute("array");
79+
// if (elArray && attribute.name === "array" && elArray !== attribute.value) break;
7980
// Set the value of the attribute.
80-
// TODO: skip-attribute naming convention, perhaps skip by defualt if storage, database, array not the same and use attribute to apply for cases where one _id will be used across 2 arrays
81-
if ( !el.hasAttribute("skip-attribute") ) {
82-
el.setAttribute(attribute.name, attribute.value);
83-
}
81+
// TODO: form-attributes="false" naming convention, perhaps skip by defualt if storage, database, array not the same and use attribute to apply for cases where one _id will be used across 2 arrays
82+
el.setAttribute(attribute.name, attribute.value);
8483
}
8584
}
8685
}

0 commit comments

Comments
 (0)