diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md deleted file mode 100644 index 2aa885cfcb..0000000000 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -name: Bug report -about: Create a report to help us improve -title: '' -labels: 'Bug' -assignees: '' - ---- - -## Is this about svelte@next? This project is currently in a pre-release stage and breaking changes may occur at any time. Please do not post any kind of bug reports or questions on GitHub about it. - -**Describe the bug** -A clear and concise description of what the bug is. - -**Logs** -Please include browser console and server logs around the time this bug occurred. - -**To Reproduce** -To help us help you, if you've found a bug please consider the following: - -* If you can demonstrate the bug using https://svelte.dev/repl, please do. -* If that's not possible, we recommend creating a small repo that illustrates the problem. -* Reproductions should be small, self-contained, correct examples – http://sscce.org. - -Occasionally, this won't be possible, and that's fine – we still appreciate you raising the issue. But please understand that Svelte is run by unpaid volunteers in their free time, and issues that follow these instructions will get fixed faster. - -**Expected behavior** -A clear and concise description of what you expected to happen. - -**Stacktraces** -If you have a stack trace to include, we recommend putting inside a `
` block for the sake of the thread's readability: - -
- Stack trace - - Stack trace goes here... -
- -**Information about your Svelte project:** -To make your life easier, just run `npx envinfo --system --npmPackages svelte,rollup,webpack --binaries --browsers` and paste the output here. - -- Your browser and the version: (e.x. Chrome 52.1, Firefox 48.0, IE 10) - -- Your operating system: (e.x. OS X 10, Ubuntu Linux 19.10, Windows XP, etc) - -- Svelte version (Please check you can reproduce the issue with the latest release!) - -- Whether your project uses Webpack or Rollup - -**Severity** -How severe an issue is this bug to you? Is this annoying, blocking some users, blocking an upgrade or blocking your usage of Svelte entirely? - -Note: the more honest and specific you are here the more we will take you seriously. - -**Additional context** -Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 0000000000..38a971864b --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +1,50 @@ +name: "\U0001F41E Bug report" +description: Report an issue with Svelte +labels: ["triage: bug"] +body: + - type: markdown + attributes: + value: | + Thanks for taking the time to fill out this bug report! + - type: textarea + id: bug-description + attributes: + label: Describe the bug + description: A clear and concise description of what the bug is. If you intend to submit a PR for this issue, tell us in the description. Thanks! + placeholder: Bug description + validations: + required: true + - type: textarea + id: reproduction + attributes: + label: Reproduction + description: Please provide a link to a repo or REPL that can reproduce the problem you ran into. If a report is vague (e.g. just a generic error message) and has no reproduction, it will receive a "need reproduction" label. If no reproduction is provided within a reasonable time-frame, the issue will be closed. + placeholder: Reproduction + validations: + required: true + - type: textarea + id: logs + attributes: + label: Logs + description: "Please include browser console and server logs around the time this bug occurred. Optional if provided reproduction. Please try not to insert an image but copy paste the log text." + render: shell + - type: textarea + id: system-info + attributes: + label: System Info + description: Output of `npx envinfo --system --npmPackages svelte,rollup,webpack --binaries --browsers` + render: shell + placeholder: System, Binaries, Browsers + validations: + required: true + - type: dropdown + id: severity + attributes: + label: Severity + description: Select the severity of this issue + options: + - annoyance + - blocking an upgrade + - blocking all usage of svelte + validations: + required: true diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000000..ee3e5a41b9 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,5 @@ +blank_issues_enabled: false +contact_links: + - name: Discord Chat + url: https://svelte.dev/chat + about: Ask questions and discuss with other Svelte users in real time. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md deleted file mode 100644 index 923bfdb50c..0000000000 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ /dev/null @@ -1,28 +0,0 @@ ---- -name: Feature request -about: Suggest an idea for this project -title: '' -labels: 'New Feature' -assignees: '' - ---- - - - -**Is your feature request related to a problem? Please describe.** -A clear and concise description of what the problem is. For example: I'm always frustrated when [...] - -**Describe the solution you'd like** -A clear and concise description of what you want to happen. - -**Describe alternatives you've considered** -A clear and concise description of any alternative solutions or features you've considered. - -**How important is this feature to you?** -Note: the more honest and specific you are here the more we will take you seriously. - -**Additional context** -Add any other context or screenshots about the feature request here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml new file mode 100644 index 0000000000..2174f851a0 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -0,0 +1,42 @@ +name: "Feature Request" +description: Request a new Svelte feature +labels: [enhancement] +body: + - type: markdown + attributes: + value: | + Thanks for taking the time to request this feature! If your feature request is complex or substantial enough to warrant in-depth discussion, maintainers may close the issue and ask you to open an [RFC](https://github.com/sveltejs/rfcs). + - type: textarea + id: problem + attributes: + label: Describe the problem + description: Please provide a clear and concise description the problem this feature would solve. The more information you can provide here, the better. + placeholder: I'm always frustrated when... + validations: + required: true + - type: textarea + id: solution + attributes: + label: Describe the proposed solution + description: Please provide a clear and concise description of what you would like to happen. + placeholder: I would like to see... + validations: + required: true + - type: textarea + id: alternatives + attributes: + label: Alternatives considered + description: "Please provide a clear and concise description of any alternative solutions or features you've considered." + validations: + required: true + - type: dropdown + id: importance + attributes: + label: Importance + description: How important is this feature to you? + options: + - nice to have + - would make my life easier + - i cannot use svelte without it + validations: + required: true diff --git a/.github/ISSUE_TEMPLATE/questions-and-help.md b/.github/ISSUE_TEMPLATE/questions-and-help.md deleted file mode 100644 index a6e0dc6e19..0000000000 --- a/.github/ISSUE_TEMPLATE/questions-and-help.md +++ /dev/null @@ -1,12 +0,0 @@ ---- -name: Questions and help -about: If you think you need help with something related to Svelte -title: '' -labels: 'Question' -assignees: '' - ---- - -This issue tracker is intended to collect bug reports and feature requests. - -For help with installation, information on how features work, or questions about specific features of Svelte, please come and join us in the [Svelte Discord](https://svelte.dev/chat), or ask your question on [Stack Overflow](https://stackoverflow.com/questions/tagged/svelte). Any issues open for help requests will be closed to keep from clogging up the issue tracker. diff --git a/.github/stale.yml b/.github/stale.yml new file mode 100644 index 0000000000..5c0020ef2b --- /dev/null +++ b/.github/stale.yml @@ -0,0 +1,51 @@ +# Configuration for probot-stale - https://github.com/probot/stale + +# Only issues or pull requests with all of these labels are check if stale. Defaults to `[]` (disabled) +onlyLabels: [] + +# Issues or Pull Requests with these labels will never be considered stale. Set to `[]` to disable +exemptLabels: + - popular + - pinned + - security + - "[Status] Maybe Later" + +# Set to true to ignore issues in a project (defaults to false) +exemptProjects: false + +# Set to true to ignore issues in a milestone (defaults to false) +exemptMilestones: false + +# Set to true to ignore issues with an assignee (defaults to false) +exemptAssignees: false + +# Label to use when marking as stale +staleLabel: stale-bot + +# Comment to post when removing the stale label. +# unmarkComment: > +# Your comment here. + +# Limit the number of actions per hour, from 1-30. Default is 30 +limitPerRun: 30 + +# Optionally, specify configuration settings that are specific to just 'issues' or 'pulls': +pulls: + daysUntilStale: 180 + daysUntilClose: 25 + markComment: > + This pull request has been automatically marked as stale because it has not had + recent activity. It will be closed if no further activity occurs. Thank you + for your contributions. + closeComment: > + This pull request has been closed as it was previously marked as stale and saw no subsequent activity. + +issues: + daysUntilStale: 90 + daysUntilClose: 14 + markComment: > + This issue has been automatically marked as stale because it has not had + recent activity. It will be closed if no further activity occurs. Thank you + for your contributions. + closeComment: > + This issue has been closed as it was previously marked as stale and saw no subsequent activity. diff --git a/site/content/docs/01-component-format.md b/site/content/docs/01-component-format.md index 09451701a0..30c53b225f 100644 --- a/site/content/docs/01-component-format.md +++ b/site/content/docs/01-component-format.md @@ -277,6 +277,15 @@ To apply styles to a selector globally, use the `:global(...)` modifier. to this component */ color: goldenrod; } + + p:global(.red) { + /* this will apply to all

elements belonging to this + component with a class of red, even if class="red" does + not initially appear in the markup, and is instead + added at runtime. This is useful when the class + of the element is dynamically applied, for instance + when updating the element's classList property directly. */ + } ``` @@ -291,3 +300,23 @@ The `-global-` part will be removed when compiled, and the keyframe then be refe @keyframes -global-my-animation-name {...} ``` + +--- + +There should only be 1 top-level ` + +``` \ No newline at end of file diff --git a/site/content/docs/05-accessibility-warnings.md b/site/content/docs/05-accessibility-warnings.md new file mode 100644 index 0000000000..3151ef259d --- /dev/null +++ b/site/content/docs/05-accessibility-warnings.md @@ -0,0 +1,255 @@ +--- +title: Accessibility warnings +--- + +Accessibility (shortened to a11y) isn't always easy to get right, but Svelte will help by warning you if you write inaccessible markup. + +Here is a list of accessibility checks Svelte will do it for you. + +--- + +### `a11y-accesskey` + +Enforce no `accesskey` on element. Access keys are HTML attributes that allow web developers to assign keyboard shortcuts to elements. Inconsistencies between keyboard shortcuts and keyboard commands used by screenreader and keyboard only users create accessibility complications so to avoid complications, access keys should not be used. + +```sv + +

+``` + +--- + +### `a11y-aria-attributes` + +Certain reserved DOM elements do not support ARIA roles, states and properties. This is often because they are not visible, for example `meta`, `html`, `script`, `style`. This rule enforces that these DOM elements do not contain the `aria-*` props. + +```sv + + +``` + +--- + +### `a11y-autofocus` + +Enforce that `autofocus` is not used on elements. Autofocusing elements can cause usability issues for sighted and non-sighted users, alike. + +```sv + + +``` + +--- + +### `a11y-distracting-elements` + +Enforces that no distracting elements are used. Elements that can be visually distracting can cause accessibility issues with visually impaired users. Such elements are most likely deprecated, and should be avoided. + +The following elements are visually distracting: `` and ``. + +```sv + + +``` + +--- + +### `a11y-hidden` + +Certain DOM elements are useful for screen readers navigation and should not be hidden. + +```sv + +

invisible header

+``` + +--- + +### `a11y-img-redundant-alt` + +Enforce img alt attribute does not contain the word image, picture, or photo. Screenreaders already announce `img` elements as an image. There is no need to use words such as _image_, _photo_, and/or _picture_. + +```sv +Foo eating a sandwich. + + +Picture of me taking a photo of an image + + +Photo of foo being weird. + + +Image of me at a bar! + + +Picture of baz fixing a bug. +``` + +--- + +### `a11y-invalid-attribute` + +Enforce that accessibility attribute should have valid value + +```sv + +invalid +``` + +--- + +### `a11y-label-has-associated-control` + +Enforce that a label tag has a text label and an associated control. + +There are two supported ways to associate a label with a control: + +- Wrapping a control in a label tag. +- Adding `for` to a label and assigning it a DOM ID string that indicates an input on the page. + +```sv + + + + + + +``` + +--- + +### `a11y-media-has-caption` + +Providing captions for media is essential for deaf users to follow along. Captions should be a transcription or translation of the dialogue, sound effects, relevant musical cues, and other relevant audio information. Not only is this important for accessibility, but can also be useful for all users in the case that the media is unavailable (similar to `alt` text on an image when an image is unable to load). + +The captions should contain all important and relevant information to understand the corresponding media. This may mean that the captions are not a 1:1 mapping of the dialogue in the media content. However, captions are not necessary for video components with the `muted` attribute. + +```sv + + + + + + + + + +``` + +--- + +### `a11y-misplaced-role` + +Certain reserved DOM elements do not support ARIA roles, states and properties. This is often because they are not visible, for example `meta`, `html`, `script`, `style`. This rule enforces that these DOM elements do not contain the `role` props. + +```sv + + +``` + +--- + +### `a11y-misplaced-scope` + +The scope scope should be used only on `` elements. + +```sv + +
+``` + +--- + +### `a11y-missing-attribute` + +Enforce that element should have required accessibility attribute + +```sv + + + + + + + +text +``` + +--- + +### `a11y-missing-content` + +Enforce that heading elements (`h1`, `h2`, etc.) and anchors have content and that the content is accessible to screen readers + +```sv + + + + +

+``` + +--- + +### `a11y-no-onchange` + +Enforce usage of `on:blur` over/in parallel with `on:change` on select menu elements for accessibility. `on:blur` should be used instead of `on:change`, unless absolutely necessary and it causes no negative consequences for keyboard only or screen reader users. `on:blur` is a more declarative action by the user: for instance in a dropdown, using the arrow keys to toggle between options will trigger the `on:change` event in some browsers. Regardless, when a change of context results from an `on:blur` event or an `on:change` event, the user should be notified of the change unless it occurs below the currently focused element. + +```sv + + + + +``` + +--- + +### `a11y-positive-tabindex` + +Avoid positive `tabIndex` property values to synchronize the flow of the page with keyboard tab order. + +```sv + +
+``` + +--- + +### `a11y-structure` + +Warns when accessibility related elements are not in a right structure. + +```sv + +
+
Image caption
+
+``` + +--- + +### `a11y-unknown-aria-attribute` + +Invalid aria attribute. Enforces valid `aria-*` property based on [WAI-ARIA States and Properties spec](https://www.w3.org/WAI/PF/aria-1.1/states_and_properties) + +```sv + + +``` + +--- + +### `a11y-unknown-role` + +Elements with ARIA roles must use a valid, non-abstract ARIA role. A reference to role definitions can be found at [WAI-ARIA](https://www.w3.org/TR/wai-aria/#role_definitions) site. + +```sv + +
+``` diff --git a/site/content/tutorial/02-reactivity/01-reactive-assignments/app-b/App.svelte b/site/content/tutorial/02-reactivity/01-reactive-assignments/app-b/App.svelte index bc50d74cfc..dff5942d6e 100644 --- a/site/content/tutorial/02-reactivity/01-reactive-assignments/app-b/App.svelte +++ b/site/content/tutorial/02-reactivity/01-reactive-assignments/app-b/App.svelte @@ -1,11 +1,11 @@ - \ No newline at end of file + diff --git a/site/content/tutorial/02-reactivity/01-reactive-assignments/text.md b/site/content/tutorial/02-reactivity/01-reactive-assignments/text.md index b0909f1feb..15b58f0820 100644 --- a/site/content/tutorial/02-reactivity/01-reactive-assignments/text.md +++ b/site/content/tutorial/02-reactivity/01-reactive-assignments/text.md @@ -7,15 +7,15 @@ At the heart of Svelte is a powerful system of *reactivity* for keeping the DOM To demonstrate it, we first need to wire up an event handler. Replace line 9 with this: ```html - diff --git a/site/content/tutorial/06-bindings/14-component-this/app-b/InputField.svelte b/site/content/tutorial/06-bindings/14-component-this/app-b/InputField.svelte new file mode 100644 index 0000000000..e2b04b93ed --- /dev/null +++ b/site/content/tutorial/06-bindings/14-component-this/app-b/InputField.svelte @@ -0,0 +1,9 @@ + + + \ No newline at end of file diff --git a/site/content/tutorial/06-bindings/14-component-this/text.md b/site/content/tutorial/06-bindings/14-component-this/text.md new file mode 100644 index 0000000000..00af193604 --- /dev/null +++ b/site/content/tutorial/06-bindings/14-component-this/text.md @@ -0,0 +1,19 @@ +--- +title: Binding to component instances +--- + +Just as you can bind to DOM elements, you can bind to component instances themselves. For example, we can bind the instance of `` to a prop named `field` in the same way we did when binding DOM Elements + +```html + +``` + +Now we can programmatically interact with this component using `field`. + +```html + +``` + +> Note that we can't do `{field.focus}` since field is undefined when the button is first rendered and throws an error. \ No newline at end of file diff --git a/site/content/tutorial/07-lifecycle/02-ondestroy/app-a/App.svelte b/site/content/tutorial/07-lifecycle/02-ondestroy/app-a/App.svelte index 28cdb73d0d..8fdca8d81d 100644 --- a/site/content/tutorial/07-lifecycle/02-ondestroy/app-a/App.svelte +++ b/site/content/tutorial/07-lifecycle/02-ondestroy/app-a/App.svelte @@ -1,10 +1,20 @@ -

- The page has been open for - {seconds} {seconds === 1 ? 'second' : 'seconds'} -

\ No newline at end of file +
+ +

+ The Timer component has been open for + {seconds} {seconds === 1 ? 'second' : 'seconds'} +

+ {#if open} + + {/if} +
diff --git a/site/content/tutorial/07-lifecycle/02-ondestroy/app-a/Timer.svelte b/site/content/tutorial/07-lifecycle/02-ondestroy/app-a/Timer.svelte new file mode 100644 index 0000000000..0eb5a7461d --- /dev/null +++ b/site/content/tutorial/07-lifecycle/02-ondestroy/app-a/Timer.svelte @@ -0,0 +1,20 @@ + + +

+ This component executes a callback every + {interval} millisecond{interval === 1 ? '' : 's'} +

+ + diff --git a/site/content/tutorial/07-lifecycle/02-ondestroy/app-a/utils.js b/site/content/tutorial/07-lifecycle/02-ondestroy/app-a/utils.js index 7b65e75c8c..64ab7e50c7 100644 --- a/site/content/tutorial/07-lifecycle/02-ondestroy/app-a/utils.js +++ b/site/content/tutorial/07-lifecycle/02-ondestroy/app-a/utils.js @@ -1,5 +1,9 @@ import { onDestroy } from 'svelte'; export function onInterval(callback, milliseconds) { - // implementation goes here + const interval = setInterval(callback, milliseconds); + + onDestroy(() => { + // Fix the memory leak here + }); } \ No newline at end of file diff --git a/site/content/tutorial/07-lifecycle/02-ondestroy/app-b/App.svelte b/site/content/tutorial/07-lifecycle/02-ondestroy/app-b/App.svelte index 93a721ef44..49936b6617 100644 --- a/site/content/tutorial/07-lifecycle/02-ondestroy/app-b/App.svelte +++ b/site/content/tutorial/07-lifecycle/02-ondestroy/app-b/App.svelte @@ -1,11 +1,20 @@ -

- The page has been open for - {seconds} {seconds === 1 ? 'second' : 'seconds'} -

\ No newline at end of file +
+ +

+ The Timer component has been open for + {seconds} {seconds === 1 ? 'second' : 'seconds'} +

+ {#if open} + + {/if} +
diff --git a/site/content/tutorial/07-lifecycle/02-ondestroy/app-b/Timer.svelte b/site/content/tutorial/07-lifecycle/02-ondestroy/app-b/Timer.svelte new file mode 100644 index 0000000000..0eb5a7461d --- /dev/null +++ b/site/content/tutorial/07-lifecycle/02-ondestroy/app-b/Timer.svelte @@ -0,0 +1,20 @@ + + +

+ This component executes a callback every + {interval} millisecond{interval === 1 ? '' : 's'} +

+ + diff --git a/site/content/tutorial/07-lifecycle/02-ondestroy/text.md b/site/content/tutorial/07-lifecycle/02-ondestroy/text.md index 647fbaa160..34bbf83cbf 100644 --- a/site/content/tutorial/07-lifecycle/02-ondestroy/text.md +++ b/site/content/tutorial/07-lifecycle/02-ondestroy/text.md @@ -10,8 +10,8 @@ For example, we can add a `setInterval` function when our component initialises, @@ -37,7 +37,9 @@ export function onInterval(callback, milliseconds) { -``` \ No newline at end of file +``` + +Open and close the timer a few times and make sure the counter keeps ticking and the CPU load increases. This is due to a memory leak as the previous timers are not deleted. Don't forget to refresh the page before solving the example. \ No newline at end of file diff --git a/site/content/tutorial/15-context/01-context-api/text.md b/site/content/tutorial/15-context/01-context-api/text.md index 96a716dfb0..dc5f2d7e8b 100644 --- a/site/content/tutorial/15-context/01-context-api/text.md +++ b/site/content/tutorial/15-context/01-context-api/text.md @@ -19,7 +19,7 @@ setContext(key, { }); ``` -The context object can be anything you like. Like [lifecycle functions](tutorial/onmount), `setContext` and `getContext` must be called during component initialisation; since `map` isn't created until the component has mounted, our context object contains a `getMap` function rather than `map` itself. +The context object can be anything you like. Like [lifecycle functions](tutorial/onmount), `setContext` and `getContext` must be called during component initialisation. Calling it afterwards - for example inside `onMount` - will throw an error. In this example, since `map` isn't created until the component has mounted, our context object contains a `getMap` function rather than `map` itself. On the other side of the equation, in `MapMarker.svelte`, we can now get a reference to the Mapbox instance: diff --git a/site/content/tutorial/16-special-elements/01-svelte-self/app-a/App.svelte b/site/content/tutorial/16-special-elements/01-svelte-self/app-a/App.svelte index ff02fa6a42..de0b2e0179 100644 --- a/site/content/tutorial/16-special-elements/01-svelte-self/app-a/App.svelte +++ b/site/content/tutorial/16-special-elements/01-svelte-self/app-a/App.svelte @@ -3,39 +3,35 @@ let root = [ { - type: 'folder', name: 'Important work stuff', files: [ - { type: 'file', name: 'quarterly-results.xlsx' } + { name: 'quarterly-results.xlsx' } ] }, { - type: 'folder', name: 'Animal GIFs', files: [ { - type: 'folder', name: 'Dogs', files: [ - { type: 'file', name: 'treadmill.gif' }, - { type: 'file', name: 'rope-jumping.gif' } + { name: 'treadmill.gif' }, + { name: 'rope-jumping.gif' } ] }, { - type: 'folder', name: 'Goats', files: [ - { type: 'file', name: 'parkour.gif' }, - { type: 'file', name: 'rampage.gif' } + { name: 'parkour.gif' }, + { name: 'rampage.gif' } ] }, - { type: 'file', name: 'cat-roomba.gif' }, - { type: 'file', name: 'duck-shuffle.gif' }, - { type: 'file', name: 'monkey-on-a-pig.gif' } + { name: 'cat-roomba.gif' }, + { name: 'duck-shuffle.gif' }, + { name: 'monkey-on-a-pig.gif' } ] }, - { type: 'file', name: 'TODO.md' } + { name: 'TODO.md' } ]; - \ No newline at end of file + 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 20096e805e..1108b3575c 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 @@ -16,7 +16,7 @@
    {#each files as file}
  • - {#if file.type === 'folder'} + {#if file.files} {:else} @@ -49,4 +49,4 @@ li { padding: 0.2em 0; } - \ No newline at end of file + diff --git a/site/content/tutorial/16-special-elements/01-svelte-self/app-b/App.svelte b/site/content/tutorial/16-special-elements/01-svelte-self/app-b/App.svelte index ff02fa6a42..de0b2e0179 100644 --- a/site/content/tutorial/16-special-elements/01-svelte-self/app-b/App.svelte +++ b/site/content/tutorial/16-special-elements/01-svelte-self/app-b/App.svelte @@ -3,39 +3,35 @@ let root = [ { - type: 'folder', name: 'Important work stuff', files: [ - { type: 'file', name: 'quarterly-results.xlsx' } + { name: 'quarterly-results.xlsx' } ] }, { - type: 'folder', name: 'Animal GIFs', files: [ { - type: 'folder', name: 'Dogs', files: [ - { type: 'file', name: 'treadmill.gif' }, - { type: 'file', name: 'rope-jumping.gif' } + { name: 'treadmill.gif' }, + { name: 'rope-jumping.gif' } ] }, { - type: 'folder', name: 'Goats', files: [ - { type: 'file', name: 'parkour.gif' }, - { type: 'file', name: 'rampage.gif' } + { name: 'parkour.gif' }, + { name: 'rampage.gif' } ] }, - { type: 'file', name: 'cat-roomba.gif' }, - { type: 'file', name: 'duck-shuffle.gif' }, - { type: 'file', name: 'monkey-on-a-pig.gif' } + { name: 'cat-roomba.gif' }, + { name: 'duck-shuffle.gif' }, + { name: 'monkey-on-a-pig.gif' } ] }, - { type: 'file', name: 'TODO.md' } + { name: 'TODO.md' } ]; - \ No newline at end of file + diff --git a/site/content/tutorial/16-special-elements/01-svelte-self/app-b/Folder.svelte b/site/content/tutorial/16-special-elements/01-svelte-self/app-b/Folder.svelte index f5f0a7b194..11049c2e52 100644 --- a/site/content/tutorial/16-special-elements/01-svelte-self/app-b/Folder.svelte +++ b/site/content/tutorial/16-special-elements/01-svelte-self/app-b/Folder.svelte @@ -16,7 +16,7 @@
      {#each files as file}
    • - {#if file.type === 'folder'} + {#if file.files} {:else} @@ -49,4 +49,4 @@ li { padding: 0.2em 0; } - \ No newline at end of file + diff --git a/site/content/tutorial/16-special-elements/01-svelte-self/text.md b/site/content/tutorial/16-special-elements/01-svelte-self/text.md index c7946f6c6d..894a8efc3d 100644 --- a/site/content/tutorial/16-special-elements/01-svelte-self/text.md +++ b/site/content/tutorial/16-special-elements/01-svelte-self/text.md @@ -7,7 +7,7 @@ Svelte provides a variety of built-in elements. The first, ``, allo It's useful for things like this folder tree view, where folders can contain *other* folders. In `Folder.svelte` we want to be able to do this... ```html -{#if file.type === 'folder'} +{#if file.files} {:else} @@ -17,7 +17,7 @@ It's useful for things like this folder tree view, where folders can contain *ot ...but that's impossible, because a module can't import itself. Instead, we use ``: ```html -{#if file.type === 'folder'} +{#if file.files} {:else} diff --git a/site/src/server.js b/site/src/server.js index 6990d94265..cb40b56fa5 100644 --- a/site/src/server.js +++ b/site/src/server.js @@ -4,7 +4,11 @@ import sirv from 'sirv'; import * as sapper from '@sapper/server'; import { sanitize_user, authenticate } from './utils/auth'; -const { PORT = 3000 } = process.env; +if (!process.env.PORT) { + process.env.PORT = 3000; +} + +const { PORT } = process.env; const app = polka({ onError: (err, req, res) => { diff --git a/src/runtime/internal/dev.ts b/src/runtime/internal/dev.ts index 8a7415d872..4e4e5326f9 100644 --- a/src/runtime/internal/dev.ts +++ b/src/runtime/internal/dev.ts @@ -2,7 +2,7 @@ import { custom_event, append, insert, detach, listen, attr } from './dom'; import { SvelteComponent } from './Component'; export function dispatch_dev(type: string, detail?: T) { - document.dispatchEvent(custom_event(type, { version: '__VERSION__', ...detail })); + document.dispatchEvent(custom_event(type, { version: '__VERSION__', ...detail }, true)); } export function append_dev(target: Node, node: Node) { diff --git a/src/runtime/internal/dom.ts b/src/runtime/internal/dom.ts index 32756ed9a5..bdc5538941 100644 --- a/src/runtime/internal/dom.ts +++ b/src/runtime/internal/dom.ts @@ -521,9 +521,9 @@ export function toggle_class(element, name, toggle) { element.classList[toggle ? 'add' : 'remove'](name); } -export function custom_event(type: string, detail?: T) { +export function custom_event(type: string, detail?: T, bubbles: boolean = false) { const e: CustomEvent = document.createEvent('CustomEvent'); - e.initCustomEvent(type, false, false, detail); + e.initCustomEvent(type, bubbles, false, detail); return e; }