Skip to content

Commit

Permalink
fix(hiccup-dom): add NO_SPANS config
Browse files Browse the repository at this point in the history
- this avoids adding inner spans for <text> / <textfield> elements
  • Loading branch information
postspectacular committed Feb 3, 2018
1 parent d8fa4ca commit 944cbb3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/hiccup-dom/src/diff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ function normalizeElement(spec: any[]) {
return [tag, attribs, content.length > 0 ? content : undefined];
}

const NO_SPANS = { text: 1, textarea: 1 };

export function normalizeTree(el: any, path = [0], keys = true, span = true) {
if (el == null) {
return;
Expand Down Expand Up @@ -161,7 +163,7 @@ export function normalizeTree(el: any, path = [0], keys = true, span = true) {
const children = norm[2].slice(),
n = children.length;
norm.length = 2;
span = span && norm[0] !== "text";
span = span && !NO_SPANS[norm[0]];
for (let i = 0, j = 2, k = 0; i < n; i++) {
let el = children[i];
if (el != null) {
Expand Down

0 comments on commit 944cbb3

Please sign in to comment.