Skip to content

Commit 931b7f5

Browse files
committed
cePropsDefinition -> ceProps
1 parent a31d4a5 commit 931b7f5

File tree

8 files changed

+15
-18
lines changed

8 files changed

+15
-18
lines changed

elements/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1591,7 +1591,7 @@ export interface SvelteHTMLElements {
15911591
'svelte:fragment': { slot?: string };
15921592
'svelte:options': {
15931593
tag?: string | null | undefined;
1594-
cePropsDefinition?: Record<string, { attribute?: string; reflect?: boolean; type?: 'String' | 'Boolean' | 'Number' | 'Array' | 'Object' }> | undefined,
1594+
ceProps?: Record<string, { attribute?: string; reflect?: boolean; type?: 'String' | 'Boolean' | 'Number' | 'Array' | 'Object' }> | undefined,
15951595
[name: string]: any
15961596
};
15971597
'svelte:head': { [name: string]: any };

src/compiler/compile/Component.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ interface ComponentOptions {
4545
immutable?: boolean;
4646
accessors?: boolean;
4747
preserveWhitespace?: boolean;
48-
cePropsDefinition?: Record<string, { reflect?: boolean; type?: 'String' | 'Boolean' | 'Number' | 'Array' | 'Object', attribute?: string }>;
48+
ceProps?: Record<string, { reflect?: boolean; type?: 'String' | 'Boolean' | 'Number' | 'Array' | 'Object', attribute?: string }>;
4949
}
5050

5151
const regex_leading_directory_separator = /^[/\\]/;
@@ -1574,11 +1574,11 @@ function process_component_options(component: Component, nodes) {
15741574
break;
15751575
}
15761576

1577-
case 'cePropsDefinition': {
1578-
const error = () => component.error(attribute, compiler_errors.invalid_cePropsDefinition_attribute);
1577+
case 'ceProps': {
1578+
const error = () => component.error(attribute, compiler_errors.invalid_ceProps_attribute);
15791579
const { value } = attribute;
15801580
const chunk = value[0];
1581-
component_options.cePropsDefinition = {};
1581+
component_options.ceProps = {};
15821582

15831583
if (!chunk) {
15841584
break;
@@ -1593,7 +1593,7 @@ function process_component_options(component: Component, nodes) {
15931593
if (property.type !== 'Property' || property.computed || property.key.type !== 'Identifier' || property.value.type !== 'ObjectExpression') {
15941594
return error();
15951595
}
1596-
component_options.cePropsDefinition[property.key.name] = {};
1596+
component_options.ceProps[property.key.name] = {};
15971597
for (const prop of property.value.properties) {
15981598
if (prop.type !== 'Property' || prop.computed || prop.key.type !== 'Identifier' || prop.value.type !== 'Literal') {
15991599
return error();
@@ -1605,7 +1605,7 @@ function process_component_options(component: Component, nodes) {
16051605
) {
16061606
return error();
16071607
}
1608-
component_options.cePropsDefinition[property.key.name][prop.key.name] = prop.value.value;
1608+
component_options.ceProps[property.key.name][prop.key.name] = prop.value.value;
16091609
}
16101610
}
16111611

src/compiler/compile/compiler_errors.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,9 @@ export default {
206206
code: 'invalid-tag-attribute',
207207
message: "'tag' must be a string literal"
208208
},
209-
invalid_cePropsDefinition_attribute: {
210-
code: 'invalid-cePropsDefinition-attribute',
211-
message: "'cePropsDefinition' must be a statically analyzable object literal of the form " +
209+
invalid_ceProps_attribute: {
210+
code: 'invalid-ceProps-attribute',
211+
message: "'ceProps' must be a statically analyzable object literal of the form " +
212212
"'{ prop: { attribute?: string; type?: 'String' | 'Boolean' | 'Number' | 'Array' | 'Object', reflect?: boolean; } }'"
213213
},
214214
invalid_namespace_property: (namespace: string, suggestion?: string) => ({

src/compiler/compile/render_dom/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ export default function dom(
544544

545545
if (options.customElement && component.tag != null) {
546546
const props_str = writable_props.reduce((def, prop) => {
547-
def[prop.export_name] = component.component_options.cePropsDefinition?.[prop.export_name] || {};
547+
def[prop.export_name] = component.component_options.ceProps?.[prop.export_name] || {};
548548
if (prop.is_boolean && !def[prop.export_name].type) {
549549
def[prop.export_name].type = 'Boolean';
550550
}

test/custom-elements/samples/camel-case-attribute/main.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<svelte:options
22
tag="custom-element"
3-
cePropsDefinition={{
3+
ceProps={{
44
camelCase: { attribute: "camel-case" },
55
camelCase2: { reflect: true },
66
anArray: { attribute: "an-array", type: "Array", reflect: true },

test/custom-elements/samples/ce-options-valid/main.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<svelte:options
22
tag="custom-element"
3-
cePropsDefinition={{
3+
ceProps={{
44
name: { reflect: false, type: "String", attribute: "name" },
55
}}
66
/>

test/custom-elements/samples/reflect-attributes/main.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<svelte:options
22
tag="custom-element"
3-
cePropsDefinition={{ red: { reflect: true, type: "Boolean" } }}
3+
ceProps={{ red: { reflect: true, type: "Boolean" } }}
44
/>
55

66
<script>

test/custom-elements/samples/reflect-attributes/my-widget.svelte

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
<svelte:options
2-
tag="my-widget"
3-
cePropsDefinition={{ red: { reflect: true } }}
4-
/>
1+
<svelte:options tag="my-widget" ceProps={{ red: { reflect: true } }} />
52

63
<script>
74
export let red = false;

0 commit comments

Comments
 (0)