Comparing version 0.0.8 to 0.0.9
40
index.js
@@ -336,2 +336,21 @@ const events = require('events'); | ||
const _normalizeUrl = src => new URL(src, baseUrl).href; | ||
const _parseAttributes = attrs => { | ||
const result = {}; | ||
for (let i = 0; i < attrs.length; i++) { | ||
const attr = attrs[i]; | ||
result[attr.name] = attr.value; | ||
} | ||
return result; | ||
}; | ||
const _formatAttributes = attributes => { | ||
const result = []; | ||
for (const name in attributes) { | ||
const value = attributes[name]; | ||
result.push({ | ||
name, | ||
value, | ||
}); | ||
} | ||
return result; | ||
}; | ||
const _parseStyle = styleString => { | ||
@@ -391,11 +410,7 @@ const style = {}; | ||
} else { | ||
const attributes = node.attrs && (() => { | ||
const result = {}; | ||
for (let i = 0; i < node.attrs.length; i++) { | ||
const attr = node.attrs[i]; | ||
result[attr.name] = attr.value; | ||
} | ||
return result; | ||
})(); | ||
const element = new HTMLElement(node.tagName, attributes, node.value); | ||
const element = new HTMLElement( | ||
node.tagName, | ||
node.attrs && _parseAttributes(node.attrs), | ||
node.value | ||
); | ||
element.parentNode = parentNode; | ||
@@ -421,2 +436,9 @@ element[setWindowSymbol](window); | ||
get attrs() { | ||
return _formatAttributes(this.attributes); | ||
} | ||
set attrs(attrs) { | ||
this.attributes = _parseAttributes(attrs); | ||
} | ||
get children() { | ||
@@ -423,0 +445,0 @@ return this.childNodes; |
{ | ||
"name": "exokit", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"main": "index.js", | ||
@@ -5,0 +5,0 @@ "dependencies": { |
82636
2668