Skip to content
This repository has been archived by the owner on Jul 28, 2023. It is now read-only.

Make attributes.length optional #107

Merged
merged 2 commits into from Nov 29, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 15 additions & 13 deletions src/runtime/vdom.js
Expand Up @@ -9,19 +9,21 @@ export default function toVdom(node) {

if (node.nodeType === 3) return node.data;

for (let i = 0; i < attributes.length; i++) {
const name = attributes[i].name;
if (name.startsWith('wp-')) {
hasWpDirectives = true;
let val = attributes[i].value;
try {
val = JSON.parse(val);
} catch (e) {}
const [, prefix, suffix] = /wp-([^:]+):?(.*)$/.exec(name);
wpDirectives[prefix] = wpDirectives[prefix] || {};
wpDirectives[prefix][suffix || 'default'] = val;
} else {
props[name] = attributes[i].value;
if (attributes) {
for (let i = 0; i < attributes?.length; i++) {
const name = attributes[i].name;
if (name.startsWith('wp-')) {
hasWpDirectives = true;
let val = attributes[i].value;
try {
val = JSON.parse(val);
} catch (e) {}
const [, prefix, suffix] = /wp-([^:]+):?(.*)$/.exec(name);
wpDirectives[prefix] = wpDirectives[prefix] || {};
wpDirectives[prefix][suffix || 'default'] = val;
} else {
props[name] = attributes[i].value;
}
}
}

Expand Down