Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Size optimization (-3b)
  • Loading branch information
developit authored May 23, 2019
commit a9a1bba20ff039d7a3567ac0505ded7741fa1e62
13 changes: 8 additions & 5 deletions src/vhtml.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ let sanitized = {};

/** Hyperscript reviver that constructs a sanitized HTML string. */
export default function h(name, attrs) {
let stack=[], s = name ? `<${name}` : '';
let stack=[], s = '';
attrs = attrs || {};
for (let i=arguments.length; i-- > 2; ) {
stack.push(arguments[i]);
Expand All @@ -26,12 +26,15 @@ export default function h(name, attrs) {
// return name(attrs, stack.reverse());
}

if (name && attrs) for (let i in attrs) {
if (attrs[i]!==false && attrs[i]!=null && i !== setInnerHTMLAttr) {
s += ` ${DOMAttributeNames[i] ? DOMAttributeNames[i] : esc(i)}="${esc(attrs[i])}"`;
if (name) {
s += '<' + name;
if (attrs) for (let i in attrs) {
if (attrs[i]!==false && attrs[i]!=null && i !== setInnerHTMLAttr) {
s += ` ${DOMAttributeNames[i] ? DOMAttributeNames[i] : esc(i)}="${esc(attrs[i])}"`;
}
}
s += '>';
}
s += name ? '>' : '';

if (emptyTags.indexOf(name) === -1) {
if (attrs[setInnerHTMLAttr]) {
Expand Down