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..e1c62ac9bd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,41 +1,76 @@ 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 + - 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' + cache: pnpm + - run: pnpm install + env: + SKIP_PREPARE: true + - 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..449f81ecd6 100644 --- a/.mocharc.js +++ b/.mocharc.js @@ -1,7 +1,7 @@ +const is_unit_test = process.env.UNIT_TEST; + module.exports = { - file: [ - 'test/test.ts' - ], + file: is_unit_test ? [] : ['test/test.ts'], require: [ 'sucrase/register' ] 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 2ca35627cf..136f106121 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,190 @@ # Svelte changelog -## Unreleased - -* Faster SSR ([#5701](https://github.com/sveltejs/svelte/pull/5701)) +## 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)) +* 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)) + +## 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/14-composition/04-optional-slots/app-a/App.svelte b/site/content/tutorial/14-composition/04-optional-slots/app-a/App.svelte index 19537cb4b3..3dd126be75 100755 --- a/site/content/tutorial/14-composition/04-optional-slots/app-a/App.svelte +++ b/site/content/tutorial/14-composition/04-optional-slots/app-a/App.svelte @@ -10,7 +10,7 @@