ripple 0.3.13 → 0.3.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/package.json +5 -30
- package/src/runtime/array.js +38 -38
- package/src/runtime/create-subscriber.js +2 -2
- package/src/runtime/internal/client/bindings.js +4 -6
- package/src/runtime/internal/client/events.js +8 -3
- package/src/runtime/internal/client/hmr.js +5 -17
- package/src/runtime/internal/client/runtime.js +1 -0
- package/src/runtime/internal/server/blocks.js +7 -9
- package/src/runtime/internal/server/index.js +14 -22
- package/src/runtime/media-query.js +34 -33
- package/src/runtime/object.js +7 -10
- package/src/runtime/proxy.js +2 -3
- package/src/runtime/reactive-value.js +23 -21
- package/src/utils/ast.js +1 -1
- package/src/utils/attributes.js +43 -0
- package/src/utils/builders.js +2 -2
- package/tests/client/basic/basic.errors.test.rsrx +1 -1
- package/tests/client/basic/basic.styling.test.rsrx +1 -1
- package/tests/client/compiler/compiler.assignments.test.rsrx +1 -1
- package/tests/client/compiler/compiler.attributes.test.rsrx +1 -1
- package/tests/client/compiler/compiler.basic.test.rsrx +13 -13
- package/tests/client/compiler/compiler.tracked-access.test.rsrx +1 -1
- package/tests/client/compiler/compiler.try-in-function.test.rsrx +1 -1
- package/tests/client/compiler/compiler.typescript.test.rsrx +1 -1
- package/tests/client/css/global-additional-cases.test.rsrx +1 -1
- package/tests/client/css/global-advanced-selectors.test.rsrx +1 -1
- package/tests/client/css/global-at-rules.test.rsrx +1 -1
- package/tests/client/css/global-basic.test.rsrx +1 -1
- package/tests/client/css/global-classes-ids.test.rsrx +1 -1
- package/tests/client/css/global-combinators.test.rsrx +1 -1
- package/tests/client/css/global-complex-nesting.test.rsrx +1 -1
- package/tests/client/css/global-edge-cases.test.rsrx +1 -1
- package/tests/client/css/global-keyframes.test.rsrx +1 -1
- package/tests/client/css/global-nested.test.rsrx +1 -1
- package/tests/client/css/global-pseudo.test.rsrx +1 -1
- package/tests/client/css/global-scoping.test.rsrx +1 -1
- package/tests/client/css/style-identifier.test.rsrx +1 -1
- package/tests/client/return.test.rsrx +1 -1
- package/tests/hydration/build-components.js +1 -1
- package/tests/server/style-identifier.test.rsrx +1 -1
- package/tests/setup-server.js +1 -1
- package/tests/utils/compiler-compat-config.test.js +1 -1
- package/src/compiler/comment-utils.js +0 -91
- package/src/compiler/errors.js +0 -77
- package/src/compiler/identifier-utils.js +0 -80
- package/src/compiler/index.d.ts +0 -127
- package/src/compiler/index.js +0 -89
- package/src/compiler/phases/1-parse/index.js +0 -3007
- package/src/compiler/phases/1-parse/style.js +0 -704
- package/src/compiler/phases/2-analyze/css-analyze.js +0 -160
- package/src/compiler/phases/2-analyze/index.js +0 -2208
- package/src/compiler/phases/2-analyze/prune.js +0 -1131
- package/src/compiler/phases/2-analyze/validation.js +0 -168
- package/src/compiler/phases/3-transform/client/index.js +0 -5264
- package/src/compiler/phases/3-transform/segments.js +0 -2125
- package/src/compiler/phases/3-transform/server/index.js +0 -1749
- package/src/compiler/phases/3-transform/stylesheet.js +0 -545
- package/src/compiler/scope.js +0 -476
- package/src/compiler/source-map-utils.js +0 -358
- package/src/compiler/types/acorn.d.ts +0 -11
- package/src/compiler/types/estree-jsx.d.ts +0 -11
- package/src/compiler/types/estree.d.ts +0 -11
- package/src/compiler/types/index.d.ts +0 -1411
- package/src/compiler/types/parse.d.ts +0 -1723
- package/src/compiler/utils.js +0 -1258
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
@import * as AST from 'estree';
|
|
3
|
-
@import {AnalysisContext} from '#compiler';
|
|
4
|
-
@import { RippleCompileError } from 'ripple/compiler';
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { error } from '../../errors.js';
|
|
8
|
-
|
|
9
|
-
const invalid_nestings = {
|
|
10
|
-
// <p> cannot contain block-level elements
|
|
11
|
-
p: new Set([
|
|
12
|
-
'address',
|
|
13
|
-
'article',
|
|
14
|
-
'aside',
|
|
15
|
-
'blockquote',
|
|
16
|
-
'details',
|
|
17
|
-
'div',
|
|
18
|
-
'dl',
|
|
19
|
-
'fieldset',
|
|
20
|
-
'figcaption',
|
|
21
|
-
'figure',
|
|
22
|
-
'footer',
|
|
23
|
-
'form',
|
|
24
|
-
'h1',
|
|
25
|
-
'h2',
|
|
26
|
-
'h3',
|
|
27
|
-
'h4',
|
|
28
|
-
'h5',
|
|
29
|
-
'h6',
|
|
30
|
-
'header',
|
|
31
|
-
'hgroup',
|
|
32
|
-
'hr',
|
|
33
|
-
'main',
|
|
34
|
-
'menu',
|
|
35
|
-
'nav',
|
|
36
|
-
'ol',
|
|
37
|
-
'p',
|
|
38
|
-
'pre',
|
|
39
|
-
'section',
|
|
40
|
-
'table',
|
|
41
|
-
'ul',
|
|
42
|
-
]),
|
|
43
|
-
// <span> cannot contain block-level elements
|
|
44
|
-
span: new Set([
|
|
45
|
-
'address',
|
|
46
|
-
'article',
|
|
47
|
-
'aside',
|
|
48
|
-
'blockquote',
|
|
49
|
-
'details',
|
|
50
|
-
'div',
|
|
51
|
-
'dl',
|
|
52
|
-
'fieldset',
|
|
53
|
-
'figcaption',
|
|
54
|
-
'figure',
|
|
55
|
-
'footer',
|
|
56
|
-
'form',
|
|
57
|
-
'h1',
|
|
58
|
-
'h2',
|
|
59
|
-
'h3',
|
|
60
|
-
'h4',
|
|
61
|
-
'h5',
|
|
62
|
-
'h6',
|
|
63
|
-
'header',
|
|
64
|
-
'hgroup',
|
|
65
|
-
'hr',
|
|
66
|
-
'main',
|
|
67
|
-
'menu',
|
|
68
|
-
'nav',
|
|
69
|
-
'ol',
|
|
70
|
-
'p',
|
|
71
|
-
'pre',
|
|
72
|
-
'section',
|
|
73
|
-
'table',
|
|
74
|
-
'ul',
|
|
75
|
-
]),
|
|
76
|
-
// Interactive elements cannot be nested
|
|
77
|
-
a: new Set(['a', 'button']),
|
|
78
|
-
button: new Set(['a', 'button']),
|
|
79
|
-
// Form elements
|
|
80
|
-
label: new Set(['label']),
|
|
81
|
-
form: new Set(['form']),
|
|
82
|
-
// Headings cannot be nested within each other
|
|
83
|
-
h1: new Set(['h1', 'h2', 'h3', 'h4', 'h5', 'h6']),
|
|
84
|
-
h2: new Set(['h1', 'h2', 'h3', 'h4', 'h5', 'h6']),
|
|
85
|
-
h3: new Set(['h1', 'h2', 'h3', 'h4', 'h5', 'h6']),
|
|
86
|
-
h4: new Set(['h1', 'h2', 'h3', 'h4', 'h5', 'h6']),
|
|
87
|
-
h5: new Set(['h1', 'h2', 'h3', 'h4', 'h5', 'h6']),
|
|
88
|
-
h6: new Set(['h1', 'h2', 'h3', 'h4', 'h5', 'h6']),
|
|
89
|
-
// Table structure
|
|
90
|
-
table: new Set(['table', 'tr', 'td', 'th']), // Can only contain caption, colgroup, thead, tbody, tfoot
|
|
91
|
-
thead: new Set(['caption', 'colgroup', 'thead', 'tbody', 'tfoot', 'td', 'th']), // Can only contain tr
|
|
92
|
-
tbody: new Set(['caption', 'colgroup', 'thead', 'tbody', 'tfoot', 'td', 'th']), // Can only contain tr
|
|
93
|
-
tfoot: new Set(['caption', 'colgroup', 'thead', 'tbody', 'tfoot', 'td', 'th']), // Can only contain tr
|
|
94
|
-
tr: new Set(['caption', 'colgroup', 'thead', 'tbody', 'tfoot', 'tr']), // Can only contain td and th
|
|
95
|
-
td: new Set(['td', 'th']), // Cannot nest td/th elements
|
|
96
|
-
th: new Set(['td', 'th']), // Cannot nest td/th elements
|
|
97
|
-
// Media elements
|
|
98
|
-
picture: new Set(['picture']),
|
|
99
|
-
// Main landmark - only one per document, cannot be nested
|
|
100
|
-
main: new Set(['main']),
|
|
101
|
-
// Other semantic restrictions
|
|
102
|
-
figcaption: new Set(['figcaption']),
|
|
103
|
-
dt: new Set([
|
|
104
|
-
'header',
|
|
105
|
-
'footer',
|
|
106
|
-
'article',
|
|
107
|
-
'aside',
|
|
108
|
-
'nav',
|
|
109
|
-
'section',
|
|
110
|
-
'h1',
|
|
111
|
-
'h2',
|
|
112
|
-
'h3',
|
|
113
|
-
'h4',
|
|
114
|
-
'h5',
|
|
115
|
-
'h6',
|
|
116
|
-
]),
|
|
117
|
-
// No interactive content inside summary
|
|
118
|
-
summary: new Set(['summary']),
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* @param {AST.Element} element
|
|
123
|
-
* @returns {string | null}
|
|
124
|
-
*/
|
|
125
|
-
function get_element_tag(element) {
|
|
126
|
-
return element.id.type === 'Identifier' ? element.id.name : null;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* @param {AST.Element} element
|
|
131
|
-
* @param {AnalysisContext} context
|
|
132
|
-
* @param {RippleCompileError[]} [errors]
|
|
133
|
-
*/
|
|
134
|
-
export function validate_nesting(element, context, errors) {
|
|
135
|
-
const tag = get_element_tag(element);
|
|
136
|
-
|
|
137
|
-
if (tag === null) {
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
for (let i = context.path.length - 1; i >= 0; i--) {
|
|
142
|
-
const parent = context.path[i];
|
|
143
|
-
if (parent.type === 'Element') {
|
|
144
|
-
const parent_tag = get_element_tag(parent);
|
|
145
|
-
if (parent_tag === null) {
|
|
146
|
-
continue;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
if (parent_tag in invalid_nestings) {
|
|
150
|
-
const validation_set =
|
|
151
|
-
invalid_nestings[/** @type {keyof typeof invalid_nestings} */ (parent_tag)];
|
|
152
|
-
if (validation_set.has(tag)) {
|
|
153
|
-
error(
|
|
154
|
-
`Invalid HTML nesting: <${tag}> cannot be a descendant of <${parent_tag}>.`,
|
|
155
|
-
context.state.analysis.module.filename,
|
|
156
|
-
element,
|
|
157
|
-
errors,
|
|
158
|
-
context.state.analysis.comments,
|
|
159
|
-
);
|
|
160
|
-
} else {
|
|
161
|
-
// if my parent has a set of invalid children
|
|
162
|
-
// and i'm not in it, then i'm valid
|
|
163
|
-
return;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
}
|