Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (isText(node)) {
return {
[Shortcuts.Text]: node.nodeValue,
[Shortcuts.NodeName]: node.nodeName
}
}
const data: MiniData = {
...node.props,
[Shortcuts.Childnodes]: node.childNodes.map(hydrate),
[Shortcuts.NodeName]: node.nodeName,
uid: node.uid
}
if (node.className) {
data[Shortcuts.Class] = node.className
}
if (node.cssText) {
data[Shortcuts.Style] = node.cssText
}
// eslint-disable-next-line dot-notation
delete data['class']
// eslint-disable-next-line dot-notation
delete data['style']
return data
}
public setAttribute (qualifiedName: string, value: string | boolean): void {
if (qualifiedName === 'style') {
this.style.cssText = value as string
qualifiedName = Shortcuts.Style
} else if (qualifiedName === 'id') {
eventSource.delete(this.uid)
this.uid = value as string
eventSource.set(value as string, this)
qualifiedName = 'uid'
} else {
this.props[qualifiedName] = value as string
if (qualifiedName === 'class') {
qualifiedName = Shortcuts.Class
}
if (qualifiedName.startsWith('data-')) {
if (this.dataset === EMPTY_OBJ) {
this.dataset = Object.create(null)
}
this.dataset[qualifiedName.replace(/^data-/, '')] = value
}
}
this.enqueueUpdate({
path: `${this._path}.${qualifiedName}`,
value
})
}