diff --git a/.eslintrc.js b/.eslintrc.js index a093de610b..66c533eb5d 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -10,5 +10,8 @@ module.exports = { 'estree' ], 'svelte3/compiler': require('./compiler') + }, + rules: { + '@typescript-eslint/no-non-null-assertion': 'off' } }; diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 7de5a35e13..05b48f2ae0 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,6 +1,6 @@ ### Before submitting the PR, please make sure you do the following - [ ] It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs -- [ ] Prefix your PR title with `[feat]`, `[fix]`, `[chore]`, or `[docs]`. +- [ ] Prefix your PR title with `feat:`, `fix:`, `chore:`, or `docs:`. - [ ] This message body should clearly illustrate what problems it solves. - [ ] Ideally, include a test that fails without this PR but passes with it. diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bbfde04f67..91cd471aa2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,41 +1,77 @@ name: CI -on: [push, pull_request] +on: + push: + branches: [ master ] + pull_request: +permissions: + contents: read # to fetch code (actions/checkout) jobs: Tests: runs-on: ${{ matrix.os }} timeout-minutes: 15 strategy: matrix: - node-version: [8, 10, 12, 14, 16] - os: [ubuntu-latest, windows-latest, macOS-latest] + include: + - node-version: 14 + os: ubuntu-latest + - node-version: 14 + os: windows-latest + - node-version: 14 + os: macOS-latest + - node-version: 16 + os: ubuntu-latest + - node-version: 18 + os: ubuntu-latest + - node-version: 20 + os: ubuntu-latest steps: - - uses: actions/checkout@v1 - - uses: actions/setup-node@v2 + - uses: actions/checkout@v3 + - uses: pnpm/action-setup@v2.2.4 + with: + version: ${{ matrix.node-version == 14 && 7 || 8 }} + - uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-version }} - cache: npm - - run: npm install - - run: npm test + cache: pnpm + - run: pnpm install --frozen-lockfile + - run: node node_modules/puppeteer/install.js + - run: pnpm test:integration env: CI: true Lint: runs-on: ubuntu-latest timeout-minutes: 5 steps: - - uses: actions/checkout@v1 - - uses: actions/setup-node@v2 + - uses: actions/checkout@v3 + - uses: pnpm/action-setup@v2.2.4 + - uses: actions/setup-node@v3 with: - cache: npm - - run: 'npm i && npm run lint' + cache: pnpm + - run: 'pnpm i && pnpm lint' Unit: runs-on: ${{ matrix.os }} timeout-minutes: 10 strategy: matrix: - os: [ubuntu-latest, windows-latest, macOS-latest] + include: + - node-version: 14 + os: ubuntu-latest + - node-version: 14 + os: windows-latest + - node-version: 14 + os: macOS-latest + - node-version: 16 + os: ubuntu-latest + - node-version: 18 + os: ubuntu-latest + - node-version: 20 + os: ubuntu-latest steps: - - uses: actions/checkout@v1 - - uses: actions/setup-node@v2 + - uses: actions/checkout@v3 + - uses: pnpm/action-setup@v2.2.4 + - uses: actions/setup-node@v3 with: - cache: npm - - run: 'npm i && npm run test:unit' + node-version: ${{ matrix.node-version }} + cache: pnpm + - run: pnpm install + - run: pnpm test:unit diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index ea6e0f5a60..763fb72577 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -7,6 +7,8 @@ on: paths: - site/content/** +permissions: {} + jobs: release: name: Deploy docs @@ -25,4 +27,4 @@ jobs: repo: 'svelte' branch: 'master' docs_path: 'site/content' - token: ${{ steps.github-app.outputs.token }} \ No newline at end of file + token: ${{ steps.github-app.outputs.token }} diff --git a/.gitignore b/.gitignore index 478a6f5ceb..e70d995994 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,4 @@ node_modules _actual*.* _output /types +.eslintcache diff --git a/.mocharc.js b/.mocharc.js index e55f26099e..c8ae961f89 100644 --- a/.mocharc.js +++ b/.mocharc.js @@ -1,9 +1,12 @@ +const is_unit_test = process.env.UNIT_TEST; + module.exports = { - file: [ - 'test/test.ts' - ], + file: is_unit_test ? [] : ['test/test.js'], require: [ 'sucrase/register' + ], + "node-option": [ + "experimental-modules" ] }; diff --git a/.mocharc.unit.js b/.mocharc.unit.js new file mode 100644 index 0000000000..387d70e7e0 --- /dev/null +++ b/.mocharc.unit.js @@ -0,0 +1,15 @@ +module.exports = { + spec: [ + 'src/**/__test__.ts', + ], + require: [ + 'sucrase/register' + ], + recursive: true, +}; + +// add coverage options when running 'npx c8 mocha' +if (process.env.NODE_V8_COVERAGE) { + module.exports.fullTrace = true; + module.exports.require.push('source-map-support/register'); +} diff --git a/CHANGELOG.md b/CHANGELOG.md index db61c31273..437d084faf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,23 +1,163 @@ # Svelte changelog -hi - -## Unreleased +## Unreleased (4.0) + +* **breaking** Minimum supported Node version is now Node 14 +* **breaking** Minimum supported webpack version is now webpack 5 +* **breaking** Minimum supported TypeScript version is now TypeScript 5 (it will likely work with lower versions, but we make no guarantees about that) +* **breaking** Stricter types for `createEventDispatcher` (see PR for migration instructions) ([#7224](https://github.com/sveltejs/svelte/pull/7224)) +* **breaking** Stricter types for `Action` and `ActionReturn` (see PR for migration instructions) ([#7224](https://github.com/sveltejs/svelte/pull/7224)) +* **breaking** Stricter types for `onMount` - now throws a type error when returning a function asynchronously to catch potential mistakes around callback functions (see PR for migration instructions) ([#8136](https://github.com/sveltejs/svelte/pull/8136)) +* **breaking** Overhaul and drastically improve creating custom elements with Svelte (see PR for list of changes and migration instructions) ([#8457](https://github.com/sveltejs/svelte/pull/8457)) +* **breaking** Deprecate `SvelteComponentTyped`, use `SvelteComponent` instead ([#8512](https://github.com/sveltejs/svelte/pull/8512)) +* **breaking** Error on falsy values instead of stores passed to `derived` ([#7947](https://github.com/sveltejs/svelte/pull/7947)) +* **breaking** Custom store implementers now need to pass an `update` function additionally to the `set` function ([#6750](https://github.com/sveltejs/svelte/pull/6750)) +* Add `a11y no-noninteractive-element-interactions` rule ([#8391](https://github.com/sveltejs/svelte/pull/8391)) +* Add `a11y-no-static-element-interactions`rule ([#8251](https://github.com/sveltejs/svelte/pull/8251)) +* Bind `null` option and input values consistently ([#8312](https://github.com/sveltejs/svelte/issues/8312)) +* Allow `$store` to be used with changing values including nullish values ([#7555](https://github.com/sveltejs/svelte/issues/7555)) +* Initialize stylesheet with `/* empty */` to enable setting CSP directive that also works in Safari ([#7800](https://github.com/sveltejs/svelte/pull/7800)) +* Treat slots as if they don't exist when using CSS adjacent and general sibling combinators ([#8284](https://github.com/sveltejs/svelte/issues/8284)) + +## Unreleased (3.0) + +* Handle `width`/`height` attributes when spreading ([#6752](https://github.com/sveltejs/svelte/issues/6752)) +* Add support for resize observer bindings (`
`) ([#8022](https://github.com/sveltejs/svelte/pull/8022)) + +## 3.58.0 + +* Add `bind:innerText` for `contenteditable` elements ([#3311](https://github.com/sveltejs/svelte/issues/3311)) +* Add support for CSS `@container` queries ([#6969](https://github.com/sveltejs/svelte/issues/6969)) +* Respect `preserveComments` in DOM output ([#7182](https://github.com/sveltejs/svelte/pull/7182)) +* Allow use of `document` for `target` in typings ([#7554](https://github.com/sveltejs/svelte/pull/7554)) +* Add `a11y-interactive-supports-focus` warning ([#8392](https://github.com/sveltejs/svelte/pull/8392)) +* Fix equality check when updating dynamic text ([#5931](https://github.com/sveltejs/svelte/issues/5931)) +* Relax `a11y-no-noninteractive-element-to-interactive-role` warning ([#8402](https://github.com/sveltejs/svelte/pull/8402)) +* Properly handle microdata attributes ([#8413](https://github.com/sveltejs/svelte/issues/8413)) +* Prevent name collision when using computed destructuring variables ([#8417](https://github.com/sveltejs/svelte/issues/8417)) +* Fix escaping ` @@ -14,4 +13,4 @@ In cases like these, where the names match, we can also use a shorthand form: ``` -This applies to all bindings, not just textareas. \ No newline at end of file +This applies to all bindings, not just textareas. diff --git a/site/content/tutorial/06-bindings/08-contenteditable-bindings/text.md b/site/content/tutorial/06-bindings/08-contenteditable-bindings/text.md index a73b07c0ba..4d4b52f3b8 100644 --- a/site/content/tutorial/06-bindings/08-contenteditable-bindings/text.md +++ b/site/content/tutorial/06-bindings/08-contenteditable-bindings/text.md @@ -2,11 +2,16 @@ title: Contenteditable bindings --- -Elements with a `contenteditable="true"` attribute support `textContent` and `innerHTML` bindings: +Elements with the `contenteditable` attribute support the following bindings: +- [`innerHTML`](https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML) +- [`innerText`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/innerText) +- [`textContent`](https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent) + +There are slight differences between each of these, read more about them [here](https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent#Differences_from_innerText). ```html
-``` \ No newline at end of file +``` diff --git a/site/content/tutorial/09-motion/02-spring/app-b/App.svelte b/site/content/tutorial/09-motion/02-spring/app-b/App.svelte index d8a0287c2c..3ded9350a9 100644 --- a/site/content/tutorial/09-motion/02-spring/app-b/App.svelte +++ b/site/content/tutorial/09-motion/02-spring/app-b/App.svelte @@ -33,6 +33,7 @@ svg { width: 100%; height: 100%; + margin: -8px; } circle { fill: #ff3e00; diff --git a/site/content/tutorial/12-actions/02-adding-parameters-to-actions/app-a/longpress.js b/site/content/tutorial/12-actions/02-adding-parameters-to-actions/app-a/longpress.js index 00bb9d05c8..07235f21dc 100644 --- a/site/content/tutorial/12-actions/02-adding-parameters-to-actions/app-a/longpress.js +++ b/site/content/tutorial/12-actions/02-adding-parameters-to-actions/app-a/longpress.js @@ -18,6 +18,7 @@ export function longpress(node, duration) { return { destroy() { + clearTimeout(timer); node.removeEventListener('mousedown', handleMousedown); node.removeEventListener('mouseup', handleMouseup); } diff --git a/site/content/tutorial/12-actions/02-adding-parameters-to-actions/app-b/longpress.js b/site/content/tutorial/12-actions/02-adding-parameters-to-actions/app-b/longpress.js index 9d807cb13a..4ce0dfe05b 100644 --- a/site/content/tutorial/12-actions/02-adding-parameters-to-actions/app-b/longpress.js +++ b/site/content/tutorial/12-actions/02-adding-parameters-to-actions/app-b/longpress.js @@ -21,6 +21,7 @@ export function longpress(node, duration) { duration = newDuration; }, destroy() { + clearTimeout(timer); node.removeEventListener('mousedown', handleMousedown); node.removeEventListener('mouseup', handleMouseup); } diff --git a/site/content/tutorial/16-special-elements/01-svelte-self/app-a/Folder.svelte b/site/content/tutorial/16-special-elements/01-svelte-self/app-a/Folder.svelte index e93ffdc548..814e383924 100644 --- a/site/content/tutorial/16-special-elements/01-svelte-self/app-a/Folder.svelte +++ b/site/content/tutorial/16-special-elements/01-svelte-self/app-a/Folder.svelte @@ -10,7 +10,7 @@ } -{name} + {#if expanded}