|
|
@ -35,19 +35,17 @@ function defaultOnerror(error: Error) {
|
|
|
|
throw error;
|
|
|
|
throw error;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function parseAttributeValue(value: string | boolean) {
|
|
|
|
function parseAttributeValue(value: string) {
|
|
|
|
const curated = (<string>value).replace(/"/ig, '');
|
|
|
|
return /^['"]/.test(value) ?
|
|
|
|
if (curated === 'true' || curated === 'false') {
|
|
|
|
value.slice(1, -1) :
|
|
|
|
return curated === 'true';
|
|
|
|
value;
|
|
|
|
}
|
|
|
|
|
|
|
|
return curated;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function parseAttributes(str: string) {
|
|
|
|
function parseAttributes(str: string) {
|
|
|
|
const attrs = {};
|
|
|
|
const attrs = {};
|
|
|
|
str.split(/\s+/).filter(Boolean).forEach(attr => {
|
|
|
|
str.split(/\s+/).filter(Boolean).forEach(attr => {
|
|
|
|
const [name, value] = attr.split('=');
|
|
|
|
const [name, value] = attr.split('=');
|
|
|
|
attrs[name] = parseAttributeValue(value);
|
|
|
|
attrs[name] = value ? parseAttributeValue(value) : true;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
return attrs;
|
|
|
|
return attrs;
|
|
|
|
}
|
|
|
|
}
|
|
|
|