siphon-cli
Version:
Simple bundler for web applications. 📦🔧🧡
34 lines (33 loc) • 1.07 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var utils_1 = require("../../../utils");
function getNodeAttributes(list) {
var i = 0, key = "", value = undefined, attributes = {};
list = list.trim();
while (list[i]) {
if (list[i] === "=") {
i++;
value = "";
if (utils_1.stringMarkers.includes(list[i])) {
var marker = list[i++];
while (list[i] && list[i] !== marker)
value += list[i++];
}
else
while (list[i] && list[i] !== " ")
value += list[i++];
}
else if (list[i] === " " && key.trim() !== "") {
attributes[key.trim()] = value !== undefined ? value : true;
key = "";
value = "";
}
else {
key += list[i];
}
i++;
}
attributes[key.trim()] = value !== undefined ? value : true;
return attributes;
}
exports.default = getNodeAttributes;