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

Loading…
Cancel
Save