mirror of https://github.com/sveltejs/svelte
commit
68203da4cc
@ -1,10 +1,8 @@
|
||||
import Renderer, { RenderOptions } from '../Renderer';
|
||||
import Comment from '../../nodes/Comment';
|
||||
|
||||
export default function(_node: Comment, _renderer: Renderer, _options: RenderOptions) {
|
||||
// TODO preserve comments
|
||||
|
||||
// if (options.preserveComments) {
|
||||
// renderer.append(`<!--${node.data}-->`);
|
||||
// }
|
||||
export default function(node: Comment, renderer: Renderer, options: RenderOptions) {
|
||||
if (options.preserveComments) {
|
||||
renderer.add_string(`<!--${node.data}-->`);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
import { Node } from 'estree';
|
||||
import { analyze, Scope, extract_names, extract_identifiers } from 'periscopic';
|
||||
import { Node as PeriscopicNode, analyze, Scope, extract_names, extract_identifiers } from 'periscopic';
|
||||
|
||||
export function create_scopes(expression: Node) {
|
||||
return analyze(expression);
|
||||
return analyze(expression as PeriscopicNode);
|
||||
}
|
||||
|
||||
export { Scope, extract_names, extract_identifiers };
|
||||
|
||||
@ -0,0 +1,14 @@
|
||||
export {
|
||||
setContext,
|
||||
getContext,
|
||||
hasContext,
|
||||
tick,
|
||||
createEventDispatcher,
|
||||
SvelteComponent,
|
||||
SvelteComponentTyped
|
||||
} from './index';
|
||||
|
||||
export function onMount() {}
|
||||
export function onDestroy() {}
|
||||
export function beforeUpdate() {}
|
||||
export function afterUpdate() {}
|
||||
@ -0,0 +1,10 @@
|
||||
{
|
||||
"code": "empty-directive-name",
|
||||
"message": "Action name cannot be empty",
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 8,
|
||||
"character": 8
|
||||
},
|
||||
"pos": 8
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
<h1 use:>Hello</h1>
|
||||
@ -0,0 +1,9 @@
|
||||
export default {
|
||||
async test({ assert, component, target, window }) {
|
||||
const button = target.querySelector('button');
|
||||
const event = new window.MouseEvent('click');
|
||||
|
||||
await button.dispatchEvent(event);
|
||||
assert.equal(component.trusted, true);
|
||||
}
|
||||
};
|
||||
@ -0,0 +1,5 @@
|
||||
<script>
|
||||
export let trusted = true;
|
||||
</script>
|
||||
|
||||
<button on:click|trusted="{() => trusted = false}">Only trusted events: {trusted?'true':'false'}</button>
|
||||
@ -0,0 +1,5 @@
|
||||
export default {
|
||||
compileOptions: {
|
||||
preserveComments: true
|
||||
}
|
||||
};
|
||||
@ -0,0 +1,3 @@
|
||||
<p>before</p>
|
||||
<!-- a comment -->
|
||||
<p>after</p>
|
||||
@ -0,0 +1,3 @@
|
||||
<p>before</p>
|
||||
<!-- a comment -->
|
||||
<p>after</p>
|
||||
@ -0,0 +1,15 @@
|
||||
<script>
|
||||
// Even if otherProps contains onBlur and/or onFocus, the rule will still fail.
|
||||
// Props should be passed down explicitly for rule to pass.
|
||||
const otherProps = {
|
||||
onBlur: () => void 0,
|
||||
onFocus: () => void 0,
|
||||
};
|
||||
</script>
|
||||
|
||||
<div on:mouseover={() => void 0} />
|
||||
<div on:mouseover={() => void 0} on:focus={() => void 0} />
|
||||
<div on:mouseover={() => void 0} {...otherProps} />
|
||||
<div on:mouseout={() => void 0} />
|
||||
<div on:mouseout={() => void 0} on:blur={() => void 0} />
|
||||
<div on:mouseout={() => void 0} {...otherProps} />
|
||||
@ -0,0 +1,62 @@
|
||||
[
|
||||
{
|
||||
"code": "a11y-mouse-events-have-key-events",
|
||||
"end": {
|
||||
"character": 272,
|
||||
"column": 35,
|
||||
"line": 10
|
||||
},
|
||||
"message": "A11y: on:mouseover must be accompanied by on:focus",
|
||||
"pos": 237,
|
||||
"start": {
|
||||
"character": 237,
|
||||
"column": 0,
|
||||
"line": 10
|
||||
}
|
||||
},
|
||||
{
|
||||
"code": "a11y-mouse-events-have-key-events",
|
||||
"end": {
|
||||
"character": 384,
|
||||
"column": 51,
|
||||
"line": 12
|
||||
},
|
||||
"message": "A11y: on:mouseover must be accompanied by on:focus",
|
||||
"pos": 333,
|
||||
"start": {
|
||||
"character": 333,
|
||||
"column": 0,
|
||||
"line": 12
|
||||
}
|
||||
},
|
||||
{
|
||||
"code": "a11y-mouse-events-have-key-events",
|
||||
"end": {
|
||||
"character": 419,
|
||||
"column": 34,
|
||||
"line": 13
|
||||
},
|
||||
"message": "A11y: on:mouseout must be accompanied by on:blur",
|
||||
"pos": 385,
|
||||
"start": {
|
||||
"character": 385,
|
||||
"column": 0,
|
||||
"line": 13
|
||||
}
|
||||
},
|
||||
{
|
||||
"code": "a11y-mouse-events-have-key-events",
|
||||
"end": {
|
||||
"character": 528,
|
||||
"column": 50,
|
||||
"line": 15
|
||||
},
|
||||
"message": "A11y: on:mouseout must be accompanied by on:blur",
|
||||
"pos": 478,
|
||||
"start": {
|
||||
"character": 478,
|
||||
"column": 0,
|
||||
"line": 15
|
||||
}
|
||||
}
|
||||
]
|
||||
@ -1,16 +0,0 @@
|
||||
<select on:change={e => {}}>
|
||||
<option>foo</option>
|
||||
<option>bar</option>
|
||||
</select>
|
||||
<select on:change={e => {}} on:blur={e => {}}>
|
||||
<option>foo</option>
|
||||
<option>bar</option>
|
||||
</select>
|
||||
<select>
|
||||
<option on:change={e => {}}>foo</option>
|
||||
<option>bar</option>
|
||||
</select>
|
||||
<select>
|
||||
<option on:change={e => {}} on:blur={e => {}}>foo</option>
|
||||
<option>bar</option>
|
||||
</select>
|
||||
@ -1,32 +0,0 @@
|
||||
[
|
||||
{
|
||||
"code": "a11y-no-onchange",
|
||||
"end": {
|
||||
"character": 88,
|
||||
"column": 9,
|
||||
"line": 4
|
||||
},
|
||||
"message": "A11y: on:blur must be used instead of on:change, unless absolutely necessary and it causes no negative consequences for keyboard only or screen reader users.",
|
||||
"pos": 0,
|
||||
"start": {
|
||||
"character": 0,
|
||||
"column": 0,
|
||||
"line": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"code": "a11y-no-onchange",
|
||||
"end": {
|
||||
"character": 249,
|
||||
"column": 44,
|
||||
"line": 10
|
||||
},
|
||||
"message": "A11y: on:blur must be used instead of on:change, unless absolutely necessary and it causes no negative consequences for keyboard only or screen reader users.",
|
||||
"pos": 209,
|
||||
"start": {
|
||||
"character": 209,
|
||||
"column": 4,
|
||||
"line": 10
|
||||
}
|
||||
}
|
||||
]
|
||||
@ -0,0 +1,15 @@
|
||||
[{
|
||||
"code": "css-invalid-global",
|
||||
"message": ":global(...) can be at the start or end of a selector sequence, but not in the middle",
|
||||
"start": {
|
||||
"line": 5,
|
||||
"column": 6,
|
||||
"character": 60
|
||||
},
|
||||
"end": {
|
||||
"line": 5,
|
||||
"column": 19,
|
||||
"character": 73
|
||||
},
|
||||
"pos": 60
|
||||
}]
|
||||
@ -0,0 +1,8 @@
|
||||
<style>
|
||||
.foo :global(.bar)::after {
|
||||
color: red;
|
||||
}
|
||||
.foo :global(.bar)::after .baz {
|
||||
color: red;
|
||||
}
|
||||
</style>
|
||||
@ -0,0 +1,17 @@
|
||||
[
|
||||
{
|
||||
"code": "css-invalid-global-selector",
|
||||
"message": ":global(...) must contain a single selector",
|
||||
"start": {
|
||||
"line": 11,
|
||||
"column": 5,
|
||||
"character": 156
|
||||
},
|
||||
"end": {
|
||||
"line": 11,
|
||||
"column": 29,
|
||||
"character": 180
|
||||
},
|
||||
"pos": 156
|
||||
}
|
||||
]
|
||||
@ -0,0 +1,18 @@
|
||||
<style>
|
||||
div :global(:is(h1, h2)) {
|
||||
color: red;
|
||||
}
|
||||
div :global(:where(h1, h2)) {
|
||||
color: red;
|
||||
}
|
||||
div :global(h1 ~ :is(h2, h3)) {
|
||||
color: red;
|
||||
}
|
||||
div :global(:is(h1, h2), h3) {
|
||||
color: red;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div>
|
||||
<h1>hello world</h1>
|
||||
</div>
|
||||
@ -0,0 +1,17 @@
|
||||
[
|
||||
{
|
||||
"code": "css-invalid-global-selector",
|
||||
"message": ":global(...) must contain a single selector",
|
||||
"start": {
|
||||
"line": 5,
|
||||
"column": 5,
|
||||
"character": 77
|
||||
},
|
||||
"end": {
|
||||
"line": 5,
|
||||
"column": 44,
|
||||
"character": 116
|
||||
},
|
||||
"pos": 77
|
||||
}
|
||||
]
|
||||
@ -0,0 +1,12 @@
|
||||
<style>
|
||||
div :global(h1[data-title="Hello, world!"]) {
|
||||
color: red;
|
||||
}
|
||||
div :global(h1[attribute], video[autoplay]) {
|
||||
color: red;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div>
|
||||
<h1>hello world</h1>
|
||||
</div>
|
||||
@ -0,0 +1,17 @@
|
||||
[
|
||||
{
|
||||
"code": "css-invalid-global-selector",
|
||||
"message": ":global(...) must contain a single selector",
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 5,
|
||||
"character": 13
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 24,
|
||||
"character": 32
|
||||
},
|
||||
"pos": 13
|
||||
}
|
||||
]
|
||||
@ -0,0 +1,9 @@
|
||||
<style>
|
||||
div :global(h1, .abc\)) {
|
||||
color: red;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div>
|
||||
<h1>hello world</h1>
|
||||
</div>
|
||||
@ -0,0 +1,15 @@
|
||||
[{
|
||||
"code": "default-export",
|
||||
"message": "A component cannot have a default export",
|
||||
"pos": 10,
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 1,
|
||||
"character": 10
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 30,
|
||||
"character": 39
|
||||
}
|
||||
}]
|
||||
@ -0,0 +1,3 @@
|
||||
<script>
|
||||
export default function () {};
|
||||
</script>
|
||||
@ -0,0 +1,15 @@
|
||||
[{
|
||||
"code": "default-export",
|
||||
"message": "A component cannot have a default export",
|
||||
"pos": 10,
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 1,
|
||||
"character": 10
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 24,
|
||||
"character": 33
|
||||
}
|
||||
}]
|
||||
@ -0,0 +1,3 @@
|
||||
<script>
|
||||
export default class {};
|
||||
</script>
|
||||
@ -0,0 +1,9 @@
|
||||
export default {
|
||||
options: {
|
||||
varsReport: false
|
||||
},
|
||||
|
||||
test(assert, vars) {
|
||||
assert.deepEqual(vars, []);
|
||||
}
|
||||
};
|
||||
@ -0,0 +1,5 @@
|
||||
<script>
|
||||
export let foo = "bar";
|
||||
</script>
|
||||
|
||||
{foo}
|
||||
@ -0,0 +1,19 @@
|
||||
export default {
|
||||
options: {
|
||||
varsReport: 'full'
|
||||
},
|
||||
|
||||
test(assert, vars) {
|
||||
assert.deepEqual(vars, [{
|
||||
name: 'foo',
|
||||
export_name: null,
|
||||
injected: false,
|
||||
module: false,
|
||||
mutated: false,
|
||||
reassigned: false,
|
||||
referenced: true,
|
||||
referenced_from_script: false,
|
||||
writable: false
|
||||
}]);
|
||||
}
|
||||
};
|
||||
@ -0,0 +1 @@
|
||||
{foo}
|
||||
@ -0,0 +1,31 @@
|
||||
export default {
|
||||
options: {
|
||||
varsReport: 'full'
|
||||
},
|
||||
|
||||
test(assert, vars) {
|
||||
assert.deepEqual(vars, [
|
||||
{
|
||||
name: 'foo',
|
||||
export_name: 'foo',
|
||||
injected: false,
|
||||
module: false,
|
||||
mutated: false,
|
||||
reassigned: false,
|
||||
referenced: true,
|
||||
referenced_from_script: false,
|
||||
writable: true
|
||||
}, {
|
||||
name: 'bar',
|
||||
export_name: null,
|
||||
injected: false,
|
||||
module: false,
|
||||
mutated: false,
|
||||
reassigned: false,
|
||||
referenced: true,
|
||||
referenced_from_script: false,
|
||||
writable: false
|
||||
}
|
||||
]);
|
||||
}
|
||||
};
|
||||
@ -0,0 +1,5 @@
|
||||
<script>
|
||||
export let foo = "bar";
|
||||
</script>
|
||||
|
||||
{foo} {bar}
|
||||
@ -0,0 +1,19 @@
|
||||
export default {
|
||||
options: {
|
||||
varsReport: 'full'
|
||||
},
|
||||
|
||||
test(assert, vars) {
|
||||
assert.deepEqual(vars, [{
|
||||
name: 'foo',
|
||||
export_name: null,
|
||||
injected: false,
|
||||
module: false,
|
||||
mutated: false,
|
||||
reassigned: false,
|
||||
referenced: true,
|
||||
referenced_from_script: false,
|
||||
writable: false
|
||||
}]);
|
||||
}
|
||||
};
|
||||
@ -0,0 +1,3 @@
|
||||
<script></script>
|
||||
|
||||
{foo}
|
||||
Loading…
Reference in new issue