diff --git a/LICENSE b/LICENSE index 939579e8bd..b63fe48148 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2016 [these people](https://github.com/sveltejs/svelte/graphs/contributors) +Copyright (c) 2016-19 [these people](https://github.com/sveltejs/svelte/graphs/contributors) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: diff --git a/site/README.md b/site/README.md index 223830b3fa..1ba94e8b56 100644 --- a/site/README.md +++ b/site/README.md @@ -29,4 +29,4 @@ BASEURL=http://localhost:3000 Anchors are automatically generated using headings in the documentation and by default (for the english language) they are latinised to make sure the URL is always conforming to RFC3986. -If we need to translate the API documentation to a language using unicode chars, we can setup this app to export the correct anchors by setting up `SLUG_PRESERVE_UNICODE` to `true` and `SLUG_LANG` to the ISO 639-1 two-letter language code of your choice in `config.js`. +If we need to translate the API documentation to a language using unicode chars, we can setup this app to export the correct anchors by setting up `SLUG_PRESERVE_UNICODE` to `true` in `config.js`. diff --git a/site/config.js b/site/config.js index 25dfce0c22..097bd173a8 100644 --- a/site/config.js +++ b/site/config.js @@ -1,3 +1,2 @@ export const SLUG_PRESERVE_UNICODE = false; export const SLUG_SEPARATOR = '_'; -export const SLUG_LANG = 'en'; diff --git a/site/content/docs/02-template-syntax.md b/site/content/docs/02-template-syntax.md index 952272c6e1..260c3482d9 100644 --- a/site/content/docs/02-template-syntax.md +++ b/site/content/docs/02-template-syntax.md @@ -983,7 +983,7 @@ Named slots can also expose values. The `let:` directive goes on the element wit {/each} - + ``` diff --git a/site/content/docs/03-run-time.md b/site/content/docs/03-run-time.md index 843ac05e4c..0876cf3a36 100644 --- a/site/content/docs/03-run-time.md +++ b/site/content/docs/03-run-time.md @@ -573,10 +573,14 @@ component.$on(event, callback) Causes the `callback` function to be called whenever the component dispatches an `event`. +A function is returned that will remove the event listener when called. + ```js -app.$on('selected', event => { +const off = app.$on('selected', event => { console.log(event.detail.selection); }); + +off(); ``` #### `$destroy` diff --git a/site/content/tutorial/06-bindings/11-bind-this/text.md b/site/content/tutorial/06-bindings/11-bind-this/text.md index 25a7bc9169..e53b624057 100644 --- a/site/content/tutorial/06-bindings/11-bind-this/text.md +++ b/site/content/tutorial/06-bindings/11-bind-this/text.md @@ -2,7 +2,7 @@ title: This --- -The readonly `this` binding applies to every element (and component) and allows to you obtain a reference to rendered elements. For example, we can get a reference to a `` element: +The readonly `this` binding applies to every element (and component) and allows you to obtain a reference to rendered elements. For example, we can get a reference to a `` element: ```html ``` -Note that the value of `canvas` will be `undefined` until the component has mounted, so we put the logic inside the `onMount` [lifecycle function](tutorial/onmount). \ No newline at end of file +Note that the value of `canvas` will be `undefined` until the component has mounted, so we put the logic inside the `onMount` [lifecycle function](tutorial/onmount). diff --git a/site/content/tutorial/10-transitions/07-local-transitions/text.md b/site/content/tutorial/10-transitions/07-local-transitions/text.md index 7a22967ab0..400fbcaacb 100644 --- a/site/content/tutorial/10-transitions/07-local-transitions/text.md +++ b/site/content/tutorial/10-transitions/07-local-transitions/text.md @@ -4,7 +4,7 @@ title: Local transitions Ordinarily, transitions will play on elements when any container block is added or destroyed. In the example here, toggling the visibility of the entire list also applies transitions to individual list elements. -Instead, we'd like transitions to play only when individual items are added and removed — on other words, when the user drags the slider. +Instead, we'd like transitions to play only when individual items are added and removed — in other words, when the user drags the slider. We can achieve this with a *local* transition, which only plays when the immediate parent block is added or removed: @@ -12,4 +12,4 @@ We can achieve this with a *local* transition, which only plays when the immedia
{item}
-``` \ No newline at end of file +``` diff --git a/site/package-lock.json b/site/package-lock.json index a96697a7f2..67dc585991 100644 --- a/site/package-lock.json +++ b/site/package-lock.json @@ -1370,6 +1370,16 @@ "resolved": "https://registry.npmjs.org/@polka/url/-/url-0.5.0.tgz", "integrity": "sha512-oZLYFEAzUKyi3SKnXvj32ZCEGH6RDnao7COuCVhDydMS9NrCSVXhM79VaKyP5+Zc33m0QXEd2DN3UkU7OsHcfw==" }, + "@sindresorhus/slugify": { + "version": "0.9.1", + "resolved": "https://registry.npmjs.org/@sindresorhus/slugify/-/slugify-0.9.1.tgz", + "integrity": "sha512-b6heYM9dzZD13t2GOiEQTDE0qX+I1GyOotMwKh9VQqzuNiVdPVT8dM43fe9HNb/3ul+Qwd5oKSEDrDIfhq3bnQ==", + "dev": true, + "requires": { + "escape-string-regexp": "^1.0.5", + "lodash.deburr": "^4.1.0" + } + }, "@sveltejs/svelte-repl": { "version": "0.0.10", "resolved": "https://registry.npmjs.org/@sveltejs/svelte-repl/-/svelte-repl-0.0.10.tgz", @@ -1401,15 +1411,6 @@ "@types/node": "*" } }, - "accepts": { - "version": "1.3.5", - "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.5.tgz", - "integrity": "sha1-63d99gEXI6OxTopywIBcjoZ0a9I=", - "requires": { - "mime-types": "~2.1.18", - "negotiator": "0.6.1" - } - }, "acorn": { "version": "6.1.1", "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.1.1.tgz", @@ -1704,16 +1705,6 @@ "integrity": "sha512-k0KL0aWZuBt2lrxrcASWDfwOLMnodeQjodT/1SxEQAXsHANgo6ZC/VEaSEHCXt7aSTZ4/4H5LKa+tBXmW7Vtvw==", "dev": true }, - "bulk-replace": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/bulk-replace/-/bulk-replace-0.0.1.tgz", - "integrity": "sha1-8JVoKolqvUs9ngjeQJzCIuIT+d0=" - }, - "bytes": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz", - "integrity": "sha1-0ygVQE1olpn4Wk6k+odV3ROpYEg=" - }, "cache-base": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/cache-base/-/cache-base-1.0.1.tgz", @@ -2478,7 +2469,8 @@ "version": "2.1.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", - "dev": true + "dev": true, + "optional": true }, "aproba": { "version": "1.2.0", @@ -2502,13 +2494,15 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", - "dev": true + "dev": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -2525,19 +2519,22 @@ "version": "1.1.0", "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", - "dev": true + "dev": true, + "optional": true }, "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", - "dev": true + "dev": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=", - "dev": true + "dev": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -2668,7 +2665,8 @@ "version": "2.0.3", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", - "dev": true + "dev": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -2682,6 +2680,7 @@ "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", "dev": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -2698,6 +2697,7 @@ "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -2706,13 +2706,15 @@ "version": "0.0.8", "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", - "dev": true + "dev": true, + "optional": true }, "minipass": { "version": "2.3.5", "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.3.5.tgz", "integrity": "sha512-Gi1W4k059gyRbyVUZQ4mEqLm0YIUiGYfvxhF6SIlk3ui1WVxMTGfGdQ2SInh3PDrRTVvPKgULkpJtT4RH10+VA==", "dev": true, + "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -2733,6 +2735,7 @@ "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "dev": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -2821,7 +2824,8 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", - "dev": true + "dev": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -2835,6 +2839,7 @@ "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", "dev": true, + "optional": true, "requires": { "wrappy": "1" } @@ -2930,7 +2935,8 @@ "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", - "dev": true + "dev": true, + "optional": true }, "safer-buffer": { "version": "2.1.2", @@ -2972,6 +2978,7 @@ "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", "dev": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -2993,6 +3000,7 @@ "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "dev": true, + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -3041,13 +3049,15 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", - "dev": true + "dev": true, + "optional": true }, "yallist": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.3.tgz", "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==", - "dev": true + "dev": true, + "optional": true } } }, @@ -3212,14 +3222,6 @@ "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", "dev": true }, - "hepburn": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/hepburn/-/hepburn-1.1.1.tgz", - "integrity": "sha512-Ok3ZmMJN3ek4WFAL4f5t8k+BmrDRlS5qGjI4um+3cHH0SrYVzJgUTYwIfGvU8s/eWqOEY+gsINwjJSoaBG3A9g==", - "requires": { - "bulk-replace": "0.0.1" - } - }, "home-or-tmp": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/home-or-tmp/-/home-or-tmp-3.0.0.tgz", @@ -3619,11 +3621,6 @@ "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=", "dev": true }, - "keypress": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/keypress/-/keypress-0.1.0.tgz", - "integrity": "sha1-SjGI1CkbZrT2XtuZ+AaqmuKTWSo=" - }, "kind-of": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", @@ -3639,16 +3636,6 @@ "invert-kv": "^2.0.0" } }, - "limax": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/limax/-/limax-1.7.0.tgz", - "integrity": "sha512-ibcGylOXT5vry2JKfKwLWx2tZudRYWm4SzG9AE/cc5zqwW+3nQy/uPLUvfAUChRdmqxVrK6SNepmO7ZY8RoKfA==", - "requires": { - "hepburn": "^1.1.0", - "pinyin": "^2.8.3", - "speakingurl": "^14.0.1" - } - }, "load-bmfont": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/load-bmfont/-/load-bmfont-1.4.0.tgz", @@ -3693,6 +3680,12 @@ "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==", "dev": true }, + "lodash.deburr": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/lodash.deburr/-/lodash.deburr-4.1.0.tgz", + "integrity": "sha1-3bG7s+8HRYwBd7oH3hRCLLAz/5s=", + "dev": true + }, "log-symbols": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-2.2.0.tgz", @@ -3808,19 +3801,6 @@ "integrity": "sha512-KI1+qOZu5DcW6wayYHSzR/tXKCDC5Om4s1z2QJjDULzLcmf3DvzS7oluY4HCTrc+9FiKmWUgeNLg7W3uIQvxtQ==", "dev": true }, - "mime-db": { - "version": "1.38.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.38.0.tgz", - "integrity": "sha512-bqVioMFFzc2awcdJZIzR3HjZFX20QhilVS7hytkKrv7xFAn8bM1gzc/FOX2awLISvWe0PV8ptFKcon+wZ5qYkg==" - }, - "mime-types": { - "version": "2.1.22", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.22.tgz", - "integrity": "sha512-aGl6TZGnhm/li6F7yx82bJiBZwgiEa4Hf6CNr8YO+r5UHr53tSTYZb102zyU50DOWWKeOv0uQLRL0/9EiKWCog==", - "requires": { - "mime-db": "~1.38.0" - } - }, "mimic-fn": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", @@ -4001,11 +3981,6 @@ "to-regex": "^3.0.1" } }, - "negotiator": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz", - "integrity": "sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk=" - }, "nice-try": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz", @@ -4045,23 +4020,6 @@ "semver": "^5.3.0" } }, - "nodejieba": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/nodejieba/-/nodejieba-2.3.0.tgz", - "integrity": "sha512-ZzLsVuNDlrmcBQa/b8G/yegdXje2iFmktYmPksk6qLha1brKEANYqg4XPiBspF1D0y7Npho91KTmvKFcDr0UdA==", - "optional": true, - "requires": { - "nan": "~2.10.0" - }, - "dependencies": { - "nan": { - "version": "2.10.0", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.10.0.tgz", - "integrity": "sha512-bAdJv7fBLhWC+/Bls0Oza+mvTaNQtP+1RyhhhvD95pgUJz6XM5IzgmxOkItJ9tkoCiplvAnXI1tNmmUD/eScyA==", - "optional": true - } - } - }, "normalize-package-data": { "version": "2.5.0", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", @@ -4433,26 +4391,6 @@ "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=", "dev": true }, - "pinyin": { - "version": "2.8.3", - "resolved": "https://registry.npmjs.org/pinyin/-/pinyin-2.8.3.tgz", - "integrity": "sha1-MBzLQ1jM/oAlI8S9ZAphK+5NfEs=", - "requires": { - "commander": "~1.1.1", - "nodejieba": "^2.2.1", - "object-assign": "^4.0.1" - }, - "dependencies": { - "commander": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/commander/-/commander-1.1.1.tgz", - "integrity": "sha1-UNFlGGiuYOzP8KLZ80WVN2vGsEE=", - "requires": { - "keypress": "0.1.x" - } - } - } - }, "pixelmatch": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/pixelmatch/-/pixelmatch-4.0.2.tgz", @@ -5206,11 +5144,6 @@ "integrity": "sha512-7j8LYJLeY/Yb6ACbQ7F76qy5jHkp0U6jgBfJsk97bwWlVUnUWsAgpyaCvo17h0/RQGnQ036tVDomiwoI4pDkQA==", "dev": true }, - "speakingurl": { - "version": "14.0.1", - "resolved": "https://registry.npmjs.org/speakingurl/-/speakingurl-14.0.1.tgz", - "integrity": "sha512-1POYv7uv2gXoyGFpBCmpDVSNV74IfsWlDW216UPjbWufNf+bSU6GdbDsxdcxtfwb4xlI3yxzOTKClUosxARYrQ==" - }, "split-string": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz", @@ -5649,11 +5582,6 @@ "spdx-expression-parse": "^3.0.0" } }, - "vary": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", - "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=" - }, "which": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", diff --git a/site/package.json b/site/package.json index 437cf0680d..e3a0a3b67f 100644 --- a/site/package.json +++ b/site/package.json @@ -20,7 +20,6 @@ "do-not-zip": "^1.0.0", "express-session": "^1.15.6", "golden-fleece": "^1.0.9", - "limax": "^1.7.0", "marked": "^0.6.1", "node-fetch": "^2.3.0", "passport": "^0.4.0", @@ -38,6 +37,7 @@ "@babel/plugin-transform-runtime": "^7.2.0", "@babel/preset-env": "^7.3.1", "@babel/runtime": "^7.3.1", + "@sindresorhus/slugify": "^0.9.1", "@sveltejs/svelte-repl": "0.0.10", "chokidar": "^2.1.2", "degit": "^2.1.3", diff --git a/site/src/routes/examples/index.svelte b/site/src/routes/examples/index.svelte index ccc03c4680..269d9388cf 100644 --- a/site/src/routes/examples/index.svelte +++ b/site/src/routes/examples/index.svelte @@ -97,11 +97,9 @@
-
+
-
+
- + %sapper.base% diff --git a/site/src/utils/slug.js b/site/src/utils/slug.js index 4ad7b96b2a..79b82c12ce 100644 --- a/site/src/utils/slug.js +++ b/site/src/utils/slug.js @@ -1,14 +1,20 @@ -import limax from 'limax'; -import {SLUG_LANG, SLUG_SEPARATOR} from '../../config'; +import slugify from '@sindresorhus/slugify'; +import {SLUG_SEPARATOR} from '../../config'; -/* latinizer processor */ +/* url-safe processor */ -export const limaxProcessor = (string, lang = SLUG_LANG) => limax(string, { - custom: ['$'], - separator: SLUG_SEPARATOR, - maintainCase: true, - lang -}); +export const urlsafeSlugProcessor = string => + slugify(string, { + customReplacements: [ // runs before any other transformations + ['$', 'DOLLAR'], // `$destroy` & co + ['-', 'DASH'], // conflicts with `separator` + ], + separator: SLUG_SEPARATOR, + decamelize: false, + lowercase: false + }) + .replace(/DOLLAR/g, '$') + .replace(/DASH/g, '-'); /* unicode-preserver processor */ @@ -40,7 +46,7 @@ export const unicodeSafeProcessor = string => .chunks .reduce((accum, chunk) => { const processed = chunk.type === 'process' - ? limaxProcessor(chunk.string) + ? urlsafeSlugProcessor(chunk.string) : chunk.string; processed.length > 0 && accum.push(processed); @@ -52,7 +58,7 @@ export const unicodeSafeProcessor = string => /* session processor */ export const makeSessionSlugProcessor = (preserveUnicode = false) => { - const processor = preserveUnicode ? unicodeSafeProcessor : limaxProcessor; + const processor = preserveUnicode ? unicodeSafeProcessor : urlsafeSlugProcessor; const seen = new Set(); return string => { diff --git a/site/test/utils/slug.js b/site/test/utils/slug.js index c6d6c96685..17262c5e83 100644 --- a/site/test/utils/slug.js +++ b/site/test/utils/slug.js @@ -1,61 +1,61 @@ import {strict as assert} from 'assert'; -import {limaxProcessor, unicodeSafeProcessor} from '../../src/utils/slug'; -import {SLUG_SEPARATOR as _, SLUG_LANG} from '../../config'; +import {urlsafeSlugProcessor, unicodeSafeProcessor} from '../../src/utils/slug'; +import {SLUG_SEPARATOR as _} from '../../config'; describe('slug', () => { - describe('limaxProcessor (latinize unicode)', () => { + describe('urlsafeSlugProcessor', () => { describe('ascii', () => { it('space separated words', () => { assert.equal( - limaxProcessor('Text expressions'), - `text${_}expressions` + urlsafeSlugProcessor('Text expressions'), + `Text${_}expressions` ); }); it('numbered text', () => { assert.equal( - limaxProcessor('1. export creates'), + urlsafeSlugProcessor('1. export creates'), `1${_}export${_}creates` ); }); it('punctuated text', () => { assert.equal( - limaxProcessor('svelte.VERSION'), - `svelte${_}version` + urlsafeSlugProcessor('svelte.VERSION'), + `svelte${_}VERSION` ); }); it('text starting with the dollar sign', () => { assert.equal( - limaxProcessor('$destroy method'), + urlsafeSlugProcessor('$destroy method'), `$destroy${_}method` ); }); it('numbered text containing the dollar sign', () => { assert.equal( - limaxProcessor('1. export $destroy'), + urlsafeSlugProcessor('1. export $destroy'), `1${_}export${_}$destroy` ); }); it('text containing the equal char', () => { assert.equal( - limaxProcessor('script context=module'), + urlsafeSlugProcessor('script context=module'), `script${_}context${_}module` ); }); it('text containing the colon char', () => { assert.equal( - limaxProcessor('svelte:body'), + urlsafeSlugProcessor('svelte:body'), `svelte${_}body` ); }); it('text containing the slash char', () => { assert.equal( - limaxProcessor('svelte/motion'), + urlsafeSlugProcessor('svelte/motion'), `svelte${_}motion` ); }); it('text containing the comma char', () => { assert.equal( - limaxProcessor('svelte, motion'), + urlsafeSlugProcessor('svelte, motion'), `svelte${_}motion` ); }); @@ -63,156 +63,150 @@ describe('slug', () => { describe('unicode', () => { it('should translate symbols to English', () => { assert.equal( - limaxProcessor('Ich ♥ Deutsch'), - `ich${_}love${_}deutsch` + urlsafeSlugProcessor('Ich ♥ Deutsch'), + `Ich${_}love${_}Deutsch` ); }); it('should remove emoji', () => { assert.equal( - limaxProcessor('Ich 😍 Deutsch'), - `ich${_}deutsch` - ); - }); - it('should translate symbols to the given language (German)', () => { - assert.equal( - limaxProcessor('Ich ♥ Deutsch', 'de'), - `ich${_}liebe${_}deutsch` + urlsafeSlugProcessor('Ich 😍 Deutsch'), + `Ich${_}Deutsch` ); }); }); describe('cyricllic', () => { it('space separated words', () => { assert.equal( - limaxProcessor('Всплытие и перехват событий'), - `vsplytie${_}i${_}perekhvat${_}sobytii` + urlsafeSlugProcessor('Всплытие и перехват событий'), + `Vsplytie${_}i${_}perehvat${_}sobytij` ); }); it('numbered text', () => { assert.equal( - limaxProcessor('1 Всплытие и перехват событий'), - `1${_}vsplytie${_}i${_}perekhvat${_}sobytii` + urlsafeSlugProcessor('1 Всплытие и перехват событий'), + `1${_}Vsplytie${_}i${_}perehvat${_}sobytij` ); }); it('punctuated text', () => { assert.equal( - limaxProcessor('.Всплытие.и.перехват событий'), - `vsplytie${_}i${_}perekhvat${_}sobytii` + urlsafeSlugProcessor('.Всплытие.и.перехват событий'), + `Vsplytie${_}i${_}perehvat${_}sobytij` ); }); it('text starting with the dollar sign', () => { assert.equal( - limaxProcessor('$Всплытие $ перехват событий'), - `$vsplytie${_}$${_}perekhvat${_}sobytii` + urlsafeSlugProcessor('$Всплытие $ перехват событий'), + `$Vsplytie${_}$${_}perehvat${_}sobytij` ); }); it('text containing the dollar sign', () => { assert.equal( - limaxProcessor('Всплытие$перехват'), - `vsplytie$perekhvat` + urlsafeSlugProcessor('Всплытие$перехват'), + `Vsplytie$perehvat` ); }); it('text containing the equal char', () => { assert.equal( - limaxProcessor('Всплытие = перехват=событий'), - `vsplytie${_}perekhvat${_}sobytii` + urlsafeSlugProcessor('Всплытие = перехват=событий'), + `Vsplytie${_}perehvat${_}sobytij` ); }); it('text containing the colon char', () => { assert.equal( - limaxProcessor('Всплытие : перехват:событий'), - `vsplytie${_}perekhvat${_}sobytii` + urlsafeSlugProcessor('Всплытие : перехват:событий'), + `Vsplytie${_}perehvat${_}sobytij` ); }); it('text containing the slash char', () => { assert.equal( - limaxProcessor('Всплытие / перехват/событий'), - `vsplytie${_}perekhvat${_}sobytii` + urlsafeSlugProcessor('Всплытие / перехват/событий'), + `Vsplytie${_}perehvat${_}sobytij` ); }); it('text containing the comma char', () => { assert.equal( - limaxProcessor('Всплытие, перехват'), - `vsplytie${_}perekhvat` + urlsafeSlugProcessor('Всплытие, перехват'), + `Vsplytie${_}perehvat` ); }); }); describe('ascii + cyricllic', () => { it('space separated words', () => { assert.equal( - limaxProcessor('Всплытие и export перехват событий'), - `vsplytie${_}i${_}export${_}perekhvat${_}sobytii` + urlsafeSlugProcessor('Всплытие и export перехват событий'), + `Vsplytie${_}i${_}export${_}perehvat${_}sobytij` ); }); it('ascii word concatenated to a cyricllic word', () => { assert.equal( - limaxProcessor('exportВсплытие'), - 'exportvsplytie' + urlsafeSlugProcessor('exportВсплытие'), + 'exportVsplytie' ); }); it('cyricllic word concatenated to an ascii word', () => { assert.equal( - limaxProcessor('Всплытиеexport'), - `vsplytieexport` + urlsafeSlugProcessor('Всплытиеexport'), + `Vsplytieexport` ); }); it('numbered text', () => { assert.equal( - limaxProcessor('1 export Всплытие и перехват событий'), - `1${_}export${_}vsplytie${_}i${_}perekhvat${_}sobytii` + urlsafeSlugProcessor('1 export Всплытие и перехват событий'), + `1${_}export${_}Vsplytie${_}i${_}perehvat${_}sobytij` ); }); it('punctuated text', () => { assert.equal( - limaxProcessor('.Всплытие.export.и.перехват событий'), - `vsplytie${_}export${_}i${_}perekhvat${_}sobytii` + urlsafeSlugProcessor('.Всплытие.export.и.перехват событий'), + `Vsplytie${_}export${_}i${_}perehvat${_}sobytij` ); }); it('text starting with the dollar sign, followed by ascii char', () => { assert.equal( - limaxProcessor('$exportВсплытие перехват событий'), - `$exportvsplytie${_}perekhvat${_}sobytii` + urlsafeSlugProcessor('$exportВсплытие перехват событий'), + `$exportVsplytie${_}perehvat${_}sobytij` ); }); it('text starting with the dollar sign, followed by unicode char', () => { assert.equal( - limaxProcessor('$Всплытие export перехват событий'), - `$vsplytie${_}export${_}perekhvat${_}sobytii` + urlsafeSlugProcessor('$Всплытие export перехват событий'), + `$Vsplytie${_}export${_}perehvat${_}sobytij` ); }); it('text containing the dollar sign, followed by ascii char', () => { assert.equal( - limaxProcessor('export $destroy a component prop Всплытие и перехват событий'), - `export${_}$destroy${_}a${_}component${_}prop${_}vsplytie${_}i${_}perekhvat${_}sobytii` + urlsafeSlugProcessor('export $destroy a component prop Всплытие и перехват событий'), + `export${_}$destroy${_}a${_}component${_}prop${_}Vsplytie${_}i${_}perehvat${_}sobytij` ); }); it('text containing the dollar sign, followed by unicode char', () => { assert.equal( - limaxProcessor('Всплытие export $Всплытие a component prop Всплытие и перехват событий'), - `vsplytie${_}export${_}$vsplytie${_}a${_}component${_}prop${_}vsplytie${_}i${_}perekhvat${_}sobytii` + urlsafeSlugProcessor('Всплытие export $Всплытие a component prop Всплытие и перехват событий'), + `Vsplytie${_}export${_}$Vsplytie${_}a${_}component${_}prop${_}Vsplytie${_}i${_}perehvat${_}sobytij` ); }); it('text containing the equal char', () => { assert.equal( - limaxProcessor('script context=module Всплытие=и перехват событий'), - `script${_}context${_}module${_}vsplytie${_}i${_}perekhvat${_}sobytii` + urlsafeSlugProcessor('script context=module Всплытие=и перехват событий'), + `script${_}context${_}module${_}Vsplytie${_}i${_}perehvat${_}sobytij` ); }); it('text containing the colon char', () => { assert.equal( - limaxProcessor('svelte:body Всплытие и:перехват событий'), - `svelte${_}body${_}vsplytie${_}i${_}perekhvat${_}sobytii` + urlsafeSlugProcessor('svelte:body Всплытие и:перехват событий'), + `svelte${_}body${_}Vsplytie${_}i${_}perehvat${_}sobytij` ); }); it('text containing the slash char', () => { assert.equal( - limaxProcessor('svelte/motion Всплытие и / перехват/событий'), - `svelte${_}motion${_}vsplytie${_}i${_}perekhvat${_}sobytii` + urlsafeSlugProcessor('svelte/motion Всплытие и / перехват/событий'), + `svelte${_}motion${_}Vsplytie${_}i${_}perehvat${_}sobytij` ); }); it('text containing the comma char', () => { assert.equal( - limaxProcessor('Всплытие, export'), - `vsplytie${_}export` + urlsafeSlugProcessor('Всплытие, export'), + `Vsplytie${_}export` ); }); }); @@ -223,7 +217,7 @@ describe('slug', () => { it('space separated words', () => { assert.equal( unicodeSafeProcessor('Text expressions'), - `text${_}expressions` + `Text${_}expressions` ); }); it('numbered text', () => { @@ -235,7 +229,7 @@ describe('slug', () => { it('punctuated text', () => { assert.equal( unicodeSafeProcessor('svelte.VERSION'), - `svelte${_}version` + `svelte${_}VERSION` ); }); it('text starting with the dollar sign', () => { @@ -279,13 +273,13 @@ describe('slug', () => { it('should preserve symbols', () => { assert.equal( unicodeSafeProcessor('Ich ♥ Deutsch'), - `ich${_}love${_}deutsch` + `Ich${_}love${_}Deutsch` ); }); it('should remove emoji', () => { assert.equal( unicodeSafeProcessor('Ich 😍 Deutsch'), - `ich${_}deutsch` + `Ich${_}Deutsch` ); }); }); diff --git a/src/compile/render-ssr/Renderer.ts b/src/compile/render-ssr/Renderer.ts index 73f89dba22..c97965de14 100644 --- a/src/compile/render-ssr/Renderer.ts +++ b/src/compile/render-ssr/Renderer.ts @@ -11,7 +11,7 @@ import Slot from './handlers/Slot'; import Tag from './handlers/Tag'; import Text from './handlers/Text'; import Title from './handlers/Title'; -import { CompileOptions } from '../../interfaces'; +import { AppendTarget, CompileOptions } from '../../interfaces'; type Handler = (node: any, renderer: Renderer, options: CompileOptions) => void; @@ -36,8 +36,6 @@ const handlers: Record = { Window: noop }; -type AppendTarget = any; // TODO - export default class Renderer { has_bindings = false; code = ''; diff --git a/src/compile/render-ssr/handlers/InlineComponent.ts b/src/compile/render-ssr/handlers/InlineComponent.ts index 289f2ff8f8..bc58be5df9 100644 --- a/src/compile/render-ssr/handlers/InlineComponent.ts +++ b/src/compile/render-ssr/handlers/InlineComponent.ts @@ -4,8 +4,7 @@ import { snip } from '../../utils/snip'; import Renderer from '../Renderer'; import { stringify_props } from '../../utils/stringify_props'; import { get_slot_scope } from './shared/get_slot_scope'; - -type AppendTarget = any; // TODO +import { AppendTarget } from '../../../interfaces'; function stringify_attribute(chunk: Node) { if (chunk.type === 'Text') { @@ -111,4 +110,4 @@ export default function(node, renderer: Renderer, options) { const slots = stringify_props(slot_fns); renderer.append(`\${@validate_component(${expression}, '${node.name}').$$render($$result, ${props}, ${bindings}, ${slots})}`); -} \ No newline at end of file +}