Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 5492x 5492x 5492x 5492x 4x 5492x 2x 2x 5492x 2x 2x 2x 2x 2x 2x 1224x 1224x 1224x 1224x 8x 8x 8x 8x 1224x 4x 4x 1224x 1224x 1210x 1210x 14x 1224x 1224x 1224x 2x 2x 1224x 2x 2x 2x 2x 2x 2x 2x 241x 241x 241x 241x 2x 2x 2x 239x 239x 241x 767x 767x 767x 497x 497x 497x 497x 497x 767x 236x 236x 767x 239x 239x 236x 1x 1x 235x 235x 236x 236x 9x 236x 226x 6x 6x 220x 220x 220x 226x 5x 5x 215x 215x 215x 226x 3x 10x 6x 6x 4x 10x 4x 3x 3x 4x 1x 1x 1x 2x 226x 241x 1x 1x 241x | /** @import { AST, ElementLike } from '#compiler' */ /** @import { Context } from '../../types' */ import * as e from '../../../../errors.js'; import { is_text_attribute } from '../../../../utils/ast.js'; import * as w from '../../../../warnings.js'; import { is_custom_element_node } from '../../../nodes.js'; import { regex_only_whitespaces } from '../../../patterns.js'; /** * @param {AST.Attribute} attribute */ export function validate_attribute_name(attribute) { if ( attribute.name.includes(':') && !attribute.name.startsWith('xmlns:') && !attribute.name.startsWith('xlink:') && !attribute.name.startsWith('xml:') ) { w.attribute_illegal_colon(attribute); } } /** * @param {AST.Attribute} attribute * @param {ElementLike} parent */ export function validate_attribute(attribute, parent) { if ( Array.isArray(attribute.value) && attribute.value.length === 1 && attribute.value[0].type === 'ExpressionTag' && (parent.type === 'Component' || parent.type === 'SvelteComponent' || parent.type === 'SvelteSelf' || (parent.type === 'RegularElement' && is_custom_element_node(parent))) ) { w.attribute_quoted(attribute); } if (attribute.value === true || !Array.isArray(attribute.value) || attribute.value.length === 1) { return; } const is_quoted = attribute.value.at(-1)?.end !== attribute.end; if (!is_quoted) { e.attribute_unquoted_sequence(attribute); } } /** * @param {Context} context * @param {AST.Attribute} attribute * @param {boolean} is_component */ export function validate_slot_attribute(context, attribute, is_component = false) { const parent = context.path.at(-2); let owner = undefined; if (parent?.type === 'SnippetBlock') { if (!is_text_attribute(attribute)) { e.slot_attribute_invalid(attribute); } return; } let i = context.path.length; while (i--) { const ancestor = context.path[i]; if ( !owner && (ancestor.type === 'Component' || ancestor.type === 'SvelteComponent' || ancestor.type === 'SvelteSelf' || ancestor.type === 'SvelteElement' || (ancestor.type === 'RegularElement' && is_custom_element_node(ancestor))) ) { owner = ancestor; } } if (owner) { if (!is_text_attribute(attribute)) { e.slot_attribute_invalid(attribute); } if ( owner.type === 'Component' || owner.type === 'SvelteComponent' || owner.type === 'SvelteSelf' ) { if (owner !== parent) { e.slot_attribute_invalid_placement(attribute); } const name = attribute.value[0].data; if (context.state.component_slots.has(name)) { e.slot_attribute_duplicate(attribute, name, owner.name); } context.state.component_slots.add(name); if (name === 'default') { for (const node of owner.fragment.nodes) { if (node.type === 'Text' && regex_only_whitespaces.test(node.data)) { continue; } if (node.type === 'RegularElement' || node.type === 'SvelteFragment') { if (node.attributes.some((a) => a.type === 'Attribute' && a.name === 'slot')) { continue; } } e.slot_default_duplicate(node); } } } } else if (!is_component) { e.slot_attribute_invalid_placement(attribute); } } |