fix a bunch more tests

pull/3539/head
Richard Harris 6 years ago
parent b02028db32
commit 09c0cefe6a

@ -51,6 +51,7 @@ export default class Component {
ignore_stack: Array<Set<string>> = [];
ast: Ast;
original_ast: Ast;
source: string;
name: Identifier;
compile_options: CompileOptions;
@ -124,6 +125,15 @@ export default class Component {
this.source = source;
this.compile_options = compile_options;
// the instance JS gets mutated, so we park
// a copy here for later. TODO this feels gross
this.original_ast = {
html: ast.html,
css: ast.css,
instance: ast.instance && JSON.parse(JSON.stringify(ast.instance)),
module: ast.module
};
this.file =
compile_options.filename &&
(typeof process !== 'undefined'
@ -364,7 +374,7 @@ export default class Component {
return {
js,
css,
ast: this.ast,
ast: this.original_ast,
warnings: this.warnings,
vars: this.vars
.filter(v => !v.global && !v.internal)
@ -710,9 +720,9 @@ export default class Component {
const script = this.ast.instance;
if (!script) return;
this.warn_on_undefined_store_value_references();
this.hoist_instance_declarations();
this.extract_reactive_declarations();
this.extract_reactive_store_references();
}
// TODO merge this with other walks that are independent
@ -751,7 +761,7 @@ export default class Component {
});
}
extract_reactive_store_references() {
warn_on_undefined_store_value_references() {
// TODO this pattern happens a lot... can we abstract it
// (or better still, do fewer AST walks)?
const component = this;

@ -676,6 +676,7 @@ export default class Element extends Node {
if (modifier === 'passive') {
if (passive_events.has(handler.name)) {
console.log('here', handler.name, handler.can_make_passive);
if (handler.can_make_passive) {
component.warn(handler, {
code: 'redundant-event-modifier',

@ -39,7 +39,7 @@ export default class EventHandler extends Node {
node = declarator && declarator.init;
}
if (node && (node.type === 'FunctionExpression' || node.type === 'ArrowFunctionExpression') && node.params.length === 0) {
if (node && (node.type === 'FunctionExpression' || node.type === 'FunctionDeclaration' || node.type === 'ArrowFunctionExpression') && node.params.length === 0) {
this.can_make_passive = true;
}
}

@ -39,7 +39,7 @@ export default function dom(
const should_add_css = (
!options.customElement &&
styles.length > 0 &&
!!styles &&
options.css !== false
);

@ -36,6 +36,7 @@
]
},
"instance": {
"type": "Script",
"start": 0,
"end": 28,
"context": "default",

@ -36,6 +36,7 @@
]
},
"instance": {
"type": "Script",
"start": 0,
"end": 29,
"context": "default",

@ -30,6 +30,7 @@
]
},
"css": {
"type": "Style",
"start": 16,
"end": 56,
"attributes": [],

@ -6,6 +6,7 @@
"children": []
},
"instance": {
"type": "Script",
"start": 0,
"end": 146,
"context": "default",

@ -36,6 +36,7 @@
]
},
"instance": {
"type": "Script",
"start": 0,
"end": 28,
"context": "default",

@ -22,6 +22,7 @@
]
},
"instance": {
"type": "Script",
"start": 0,
"end": 43,
"context": "default",

@ -48,6 +48,7 @@
]
},
"instance": {
"type": "Script",
"start": 0,
"end": 77,
"context": "default",

@ -48,6 +48,7 @@
]
},
"instance": {
"type": "Script",
"start": 0,
"end": 66,
"context": "default",

@ -48,6 +48,7 @@
]
},
"instance": {
"type": "Script",
"start": 0,
"end": 39,
"context": "default",

@ -2,7 +2,7 @@ import * as fs from "fs";
import * as assert from "assert";
import { svelte, loadConfig, tryToLoadJson } from "../helpers.js";
describe("validate", () => {
describe.only("validate", () => {
fs.readdirSync("test/validator/samples").forEach(dir => {
if (dir[0] === ".") return;

Loading…
Cancel
Save