Lint and format src/compiler/compile/nodes/shared/Node.js

pull/8569/head
Simon Holthausen 3 years ago
parent 8e5fb225c6
commit c409d1bbb8

@ -1,5 +1,4 @@
export default class Node {
/**
* @readonly
* @type {number}
@ -74,39 +73,33 @@ export default class Node {
cannot_use_innerhtml() {
if (this.can_use_innerhtml !== false) {
this.can_use_innerhtml = false;
if (this.parent)
this.parent.cannot_use_innerhtml();
if (this.parent) this.parent.cannot_use_innerhtml();
}
}
not_static_content() {
this.is_static_content = false;
if (this.parent)
this.parent.not_static_content();
if (this.parent) this.parent.not_static_content();
}
/** @param {RegExp} selector */
find_nearest(selector) {
if (selector.test(this.type))
return this;
if (this.parent)
return this.parent.find_nearest(selector);
if (selector.test(this.type)) return this;
if (this.parent) return this.parent.find_nearest(selector);
}
/** @param {string} name */
get_static_attribute_value(name) {
const attribute = this.attributes &&
const attribute =
this.attributes &&
this.attributes.find(
/** @param {import('../Attribute.js').default} attr */
(attr) => attr.type === 'Attribute' && attr.name.toLowerCase() === name);
if (!attribute)
return null;
if (attribute.is_true)
return true;
if (attribute.chunks.length === 0)
return '';
(attr) => attr.type === 'Attribute' && attr.name.toLowerCase() === name
);
if (!attribute) return null;
if (attribute.is_true) return true;
if (attribute.chunks.length === 0) return '';
if (attribute.chunks.length === 1 && attribute.chunks[0].type === 'Text') {
return ( /** @type {import('../Text.js').default} */(attribute.chunks[0])).data;
return /** @type {import('../Text.js').default} */ (attribute.chunks[0]).data;
}
return null;
}
@ -116,7 +109,3 @@ export default class Node {
return this.parent ? this.parent.type === type || this.parent.has_ancestor(type) : false;
}
}

Loading…
Cancel
Save