Skip to content

Commit 62bef80

Browse files
committed
Merge remote-tracking branch 'origin/version-4' into sites
2 parents 5e4a55c + c587c8a commit 62bef80

File tree

6 files changed

+27
-18
lines changed

6 files changed

+27
-18
lines changed

.changeset/stale-cougars-wink.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
warn on boolean compilerOptions.css

documentation/docs/04-compiler-and-api/04-custom-elements-api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ console.log(el.name);
4949
el.name = 'everybody';
5050
```
5151

52-
When constructing a custom element, you can tailor several aspects by defining `customElement` as an object within `<svelte:options>`. This object comprises a mandatory `tag` property for the custom element's name, an optional `shadow` property that can be set to `"none"` to forgo shadow root creation, and a `props` option, which offers the following settings:
52+
When constructing a custom element, you can tailor several aspects by defining `customElement` as an object within `<svelte:options>`. This object comprises a mandatory `tag` property for the custom element's name, an optional `shadow` property that can be set to `"none"` to forgo shadow root creation (note that styles are then no longer encapsulated, and you can't use slots), and a `props` option, which offers the following settings:
5353

5454
- `attribute: string`: To update a custom element's prop, you have two alternatives: either set the property on the custom element's reference as illustrated above or use an HTML attribute. For the latter, the default attribute name is the lowercase property name. Modify this by assigning `attribute: "<desired name>"`.
5555
- `reflect: boolean`: By default, updated prop values do not reflect back to the DOM. To enable this behavior, set `reflect: true`.

packages/playground/start.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ import { watch } from 'rollup';
44
import serve from 'rollup-plugin-serve';
55
import * as svelte from '../svelte/src/compiler/index.js';
66

7-
const __dirname = new URL('.', import.meta.url).pathname;
7+
let __dirname = new URL('.', import.meta.url).pathname;
8+
if (process.platform === 'win32') {
9+
__dirname = __dirname.slice(1); // else path.resolve fucks up
10+
}
811

912
/** @returns {import('rollup').Plugin}*/
1013
function create_plugin(ssr = false) {

packages/svelte/src/compiler/compile/index.js

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ const regex_valid_identifier = /^[a-zA-Z_$][a-zA-Z_$0-9]*$/;
3737
const regex_starts_with_lowercase_character = /^[a-z]/;
3838

3939
let warned_of_format = false;
40+
let warned_boolean_css = false;
4041

4142
/**
4243
* @param {import('../interfaces.js').CompileOptions} options
@@ -86,23 +87,23 @@ function validate_options(options, warnings) {
8687
toString: () => message
8788
});
8889
}
89-
if (valid_css_values.indexOf(css) === -1) {
90-
throw new Error(
91-
`options.css must be true, false, 'injected', 'external', or 'none' (got '${css}')`
92-
);
93-
}
90+
9491
if (css === true || css === false) {
9592
options.css = css === true ? 'injected' : 'external';
96-
// possibly show this warning once we decided how Svelte 4 looks like
97-
// const message = `options.css as a boolean is deprecated. Use '${options.css}' instead of ${css}.`;
98-
// warnings.push({
99-
// code: 'options-css-boolean-deprecated',
100-
// message,
101-
// filename,
102-
// toString: () => message
103-
// });
104-
// }
93+
if (!warned_boolean_css) {
94+
console.warn(
95+
`compilerOptions.css as a boolean is deprecated. Use '${options.css}' instead of ${css}.`
96+
);
97+
warned_boolean_css = true;
98+
}
99+
}
100+
101+
if (!valid_css_values.includes(options.css)) {
102+
throw new Error(
103+
`compilerOptions.css must be 'injected', 'external' or 'none' (got '${options.css}').`
104+
);
105105
}
106+
106107
if (namespace && valid_namespaces.indexOf(namespace) === -1) {
107108
const match = fuzzymatch(namespace, valid_namespaces);
108109
if (match) {

packages/svelte/src/runtime/internal/Component.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ if (typeof HTMLElement === 'function') {
287287
this.$$props_definition,
288288
'toProp'
289289
);
290-
this.$$component.$set({ [attr]: this.$$data[attr] });
290+
this.$$component?.$set({ [attr]: this.$$data[attr] });
291291
}
292292

293293
disconnectedCallback() {

pnpm-lock.yaml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)