mirror of https://github.com/sveltejs/svelte
parent
ad064e9936
commit
8d38bf2be8
@ -1,18 +0,0 @@
|
|||||||
import { Node } from '../interfaces';
|
|
||||||
|
|
||||||
export default function getStaticAttributeValue(node: Node, name: string) {
|
|
||||||
const attribute = node.attributes.find(
|
|
||||||
(attr: Node) => attr.type === 'Attribute' && attr.name.toLowerCase() === name
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!attribute) return null;
|
|
||||||
|
|
||||||
if (attribute.value === true) return true;
|
|
||||||
if (attribute.value.length === 0) return '';
|
|
||||||
|
|
||||||
if (attribute.value.length === 1 && attribute.value[0].type === 'Text') {
|
|
||||||
return attribute.value[0].data;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
Loading…
Reference in new issue