Skip to content

Commit 56e99a7

Browse files
committed
Fix #14 - Allow data as attribute
1 parent cbff749 commit 56e99a7

File tree

8 files changed

+93
-12
lines changed

8 files changed

+93
-12
lines changed

cjs/handlers.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,9 @@ const handleAttribute = (node, name/*, svg*/) => {
110110
if (name === 'aria')
111111
return aria(node);
112112

113-
if (name === 'data')
113+
// some SVG node has the data attribute and if it's used as setter it flicks
114+
// see https://github.com/WebReflection/uhtml/issues/14
115+
if (name === 'data' && !(name in node))
114116
return data(node);
115117

116118
if (name.slice(0, 1) === '.')

esm/handlers.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,9 @@ const handleAttribute = (node, name/*, svg*/) => {
109109
if (name === 'aria')
110110
return aria(node);
111111

112-
if (name === 'data')
112+
// some SVG node has the data attribute and if it's used as setter it flicks
113+
// see https://github.com/WebReflection/uhtml/issues/14
114+
if (name === 'data' && !(name in node))
113115
return data(node);
114116

115117
if (name.slice(0, 1) === '.')

index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -510,8 +510,10 @@ window.uhtml = (function (exports) {
510510
/*, svg*/
511511
) {
512512
if (name === 'ref') return ref(node);
513-
if (name === 'aria') return aria(node);
514-
if (name === 'data') return data(node);
513+
if (name === 'aria') return aria(node); // some SVG node has the data attribute and if it's used as setter it flicks
514+
// see https://github.com/WebReflection/uhtml/issues/14
515+
516+
if (name === 'data' && !(name in node)) return data(node);
515517
if (name.slice(0, 1) === '.') return setter(node, name.slice(1));
516518
if (name.slice(0, 2) === 'on') return event(node, name);
517519
return attribute(node, name

min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)