fix some more tests

pull/1348/head
Rich Harris 7 years ago
parent 87a8e37150
commit cae4dd93bf

@ -47,7 +47,7 @@ export class DomGenerator extends Generator {
this.legacy = options.legacy;
this.needsEncapsulateHelper = false;
// initial values for e.g. window.innerWidth, if there's a <:Window> meta tag
// initial values for e.g. window.innerWidth, if there's a <svelte:window> meta tag
this.metaBindings = [];
}
}
@ -89,7 +89,7 @@ export default function dom(
});
if (generator.readonly.has(key)) {
// <:Window> bindings
// <svelte:window> bindings
throw new Error(
`Cannot have a computed value '${key}' that clashes with a read-only property`
);

@ -58,7 +58,7 @@ export default class Node {
if (child.type === 'Comment') return;
// special case — this is an easy way to remove whitespace surrounding
// <:Window/>. lil hacky but it works
// <svelte:window/>. lil hacky but it works
if (child.type === 'Window') {
windowComponent = child;
return;

@ -6,7 +6,7 @@ export default function validateHead(validator: Validator, node: Node, refs: Map
if (node.attributes.length) {
validator.error(node.attributes[0], {
code: `invalid-attribute`,
message: `<:Head> should not have any attributes or directives`
message: `<svelte:head> should not have any attributes or directives`
});
}

@ -23,7 +23,7 @@ export default function validateWindow(validator: Validator, node: Node, refs: M
validator.error(attribute.value, {
code: `invalid-binding`,
message: `Bindings on <:Window/> must be to top-level properties, e.g. '${parts[parts.length - 1]}' rather than '${parts.join('.')}'`
message: `Bindings on <svelte:window> must be to top-level properties, e.g. '${parts[parts.length - 1]}' rather than '${parts.join('.')}'`
});
}
@ -34,7 +34,7 @@ export default function validateWindow(validator: Validator, node: Node, refs: M
? 'innerHeight'
: fuzzymatch(attribute.name, validBindings);
const message = `'${attribute.name}' is not a valid binding on <:Window>`;
const message = `'${attribute.name}' is not a valid binding on <svelte:window>`;
if (match) {
validator.error(attribute, {

@ -1,4 +1,4 @@
<h1>Hello {{name}}!</h1>
<h1>Hello {name}!</h1>
<script>
export default {

@ -1,4 +1,4 @@
<button on:click='set({ count: count + 1 })'>count: {{count}}</button>
<button on:click='set({ count: count + 1 })'>count: {count}</button>
<script>
export default {

@ -1,5 +1,5 @@
<Counter bind:count/>
<p>clicked {{count}} times</p>
<p>clicked {count} times</p>
<script>
import Counter from './Counter.html';

@ -1,4 +1,4 @@
<h1>Hello {{name}}!</h1>
<h1>Hello {name}!</h1>
<script>
export default {

@ -1,5 +1,5 @@
<p>foo: {{foo}}</p>
<p>bar: {{bar}}</p>
<p>foo: {foo}</p>
<p>bar: {bar}</p>
<script>
export default {

@ -85,7 +85,7 @@ describe("formats", () => {
describe("amd", () => {
it("generates an AMD module", () => {
const source = deindent`
<div>{{answer}}</div>
<div>{answer}</div>
<script>
import answer from 'answer';
@ -110,7 +110,7 @@ describe("formats", () => {
describe("cjs", () => {
it("generates a CommonJS module", () => {
const source = deindent`
<div>{{answer}}</div>
<div>{answer}</div>
<script>
import answer from 'answer';
@ -134,7 +134,7 @@ describe("formats", () => {
describe("iife", () => {
it("generates a self-executing script", () => {
const source = deindent`
<div>{{answer}}</div>
<div>{answer}</div>
<script>
import answer from 'answer';
@ -208,7 +208,7 @@ describe("formats", () => {
describe("umd", () => {
it("generates a UMD build", () => {
const source = deindent`
<div>{{answer}}</div>
<div>{answer}</div>
<script>
import answer from 'answer';
@ -249,7 +249,7 @@ describe("formats", () => {
describe("eval", () => {
it("generates a self-executing script that returns the component on eval", () => {
const source = deindent`
<div>{{answer}}</div>
<div>{answer}</div>
<script>
import answer from 'answer';

@ -148,7 +148,7 @@ function data() {
function add_css() {
var style = createElement("style");
style.id = 'svelte-1a7i8ec-style';
style.textContent = "p.svelte-1a7i8ec,.svelte-1a7i8ec p{color:red}";
style.textContent = "p.svelte-1a7i8ec{color:red}";
appendNode(style, document.head);
}

@ -8,7 +8,7 @@ function data() {
function add_css() {
var style = createElement("style");
style.id = 'svelte-1a7i8ec-style';
style.textContent = "p.svelte-1a7i8ec,.svelte-1a7i8ec p{color:red}";
style.textContent = "p.svelte-1a7i8ec{color:red}";
appendNode(style, document.head);
}

@ -141,7 +141,7 @@ var proto = {
function add_css() {
var style = createElement("style");
style.id = 'svelte-1slhpfn-style';
style.textContent = "@media(min-width: 1px){div.svelte-1slhpfn,.svelte-1slhpfn div{color:red}}";
style.textContent = "@media(min-width: 1px){div.svelte-1slhpfn{color:red}}";
appendNode(style, document.head);
}

@ -4,7 +4,7 @@ import { appendNode, assign, createElement, detachNode, init, insertNode, noop,
function add_css() {
var style = createElement("style");
style.id = 'svelte-1slhpfn-style';
style.textContent = "@media(min-width: 1px){div.svelte-1slhpfn,.svelte-1slhpfn div{color:red}}";
style.textContent = "@media(min-width: 1px){div.svelte-1slhpfn{color:red}}";
appendNode(style, document.head);
}

@ -1,3 +1,3 @@
<:Window bind:scrollY=y/>
<svelte:window bind:scrollY=y/>
<p>scrolled to {y}</p>

@ -1,2 +1,2 @@
div.svelte-bzh57p,.svelte-bzh57p div{color:red}
div.svelte-4yw8vx,.svelte-4yw8vx div{color:green}
div.svelte-bzh57p{color:red}
div.svelte-4yw8vx{color:green}

@ -1 +1 @@
div.svelte-bzh57p,.svelte-bzh57p div{color:red}
div.svelte-bzh57p{color:red}

@ -1 +1 @@
{{foo.bar.baz}}
{foo.bar.baz}

@ -1,3 +1,3 @@
{{#each foo as bar}}
<span>{{bar}}</span>
{{/each}}
{#each foo as bar}
<span>{bar}</span>
{/each}

@ -1,3 +1,11 @@
<Nested>
<button slot='{foo}'>click me</button>
</Nested>
</Nested>
<script>
import Nested from './Nested.html';
export default {
components: { Nested }
};
</script>

@ -1,6 +1,6 @@
[{
"code": "invalid-binding",
"message": "'innerwidth' is not a valid binding on <:Window> (did you mean 'innerWidth'?)",
"message": "'innerwidth' is not a valid binding on <svelte:window> (did you mean 'innerWidth'?)",
"loc": {
"line": 1,
"column": 15

@ -1,6 +1,6 @@
[{
"code": "invalid-binding",
"message": "Bindings on <:Window/> must be to top-level properties, e.g. 'baz' rather than 'foo.bar.baz'",
"message": "Bindings on <svelte:window> must be to top-level properties, e.g. 'baz' rather than 'foo.bar.baz'",
"loc": {
"line": 1,
"column": 32

@ -1,6 +1,6 @@
[{
"code": "invalid-binding",
"message": "'width' is not a valid binding on <:Window> (did you mean 'innerWidth'?)",
"message": "'width' is not a valid binding on <svelte:window> (did you mean 'innerWidth'?)",
"loc": {
"line": 1,
"column": 15

@ -1,6 +1,6 @@
[{
"code": "invalid-binding",
"message": "'potato' is not a valid binding on <:Window> — valid bindings are innerWidth, innerHeight, outerWidth, outerHeight, scrollX, scrollY or online",
"message": "'potato' is not a valid binding on <svelte:window> — valid bindings are innerWidth, innerHeight, outerWidth, outerHeight, scrollX, scrollY or online",
"loc": {
"line": 1,
"column": 15

Loading…
Cancel
Save