Changes {@debug _ } to {@debug}

pull/1640/head
Admin 6 years ago
parent 79c023e604
commit a3c71af5c5

@ -1,21 +1,34 @@
import Node from './shared/Node';
import Tag from './shared/Tag';
import Block from '../dom/Block';
import Expression from './shared/Expression';
import deindent from '../../utils/deindent';
export default class DebugTag extends Tag {
export default class DebugTag extends Node {
expression: Expression;
constructor(compiler, parent, scope, info) {
super(compiler, parent, scope, info);
if (info.expression !== null)
// Debug when expression nodes change
this.expression = new Expression(compiler, parent, scope, info.expression);
else
// "Debug all"
this.expression = info.expression
}
build(
block: Block,
parentNode: string,
parentNodes: string,
) {
const { dependencies } = this.expression;
// Debug all
if (dependencies.has('_')) {
if (this.expression === null) {
block.builders.create.addLine('debugger;');
block.builders.update.addLine('debugger;');
} else {
const { dependencies } = this.expression;
const condition = [...dependencies].map(d => `changed.${d}`).join(' || ');
const identifiers = [...dependencies].join(', ');

@ -314,7 +314,13 @@ export default function mustache(parser: Parser) {
expression,
});
} else if (parser.eat('@debug')) {
const expression = readExpression(parser);
let expression;
// Implies {@debug} which indicates "debug all"
if (/\s*}/.test(parser.template[parser.index]))
expression = null;
else
expression = readExpression(parser);
parser.allowWhitespace();
parser.eat('}', true);

@ -74,19 +74,6 @@ export default function validateHtml(validator: Validator, html: Node) {
});
}
else if (node.type === 'DebugTag') {
// Only allow the `_` expression if it's by itself
// i.e. {@debug _, name } is redundantredundant-debug-all
const names = node.expression.expressions.map(e => e.name);
if (names.length > 0 && names.includes('_')) {
validator.error(node, {
code: 'redundant-debug-all',
message: `Combining other expressions with '_' is redundant`
});
}
}
if (validator.options.dev && isEmptyBlock(node)) {
validator.warn(node, {
code: `empty-block`,

@ -1,15 +0,0 @@
[{
"message": "Combining other expressions with '_' is redundant",
"start": {
"line": 1,
"column": 0,
"character": 0
},
"end":{
"line": 1,
"column": 16,
"character": 16
},
"pos": 0,
"code": "redundant-debug-all"
}]

@ -1,12 +0,0 @@
{@debug _, name}
<div>Hello {name}!</div>
<script>
export default {
data() {
return {
name: 'World'
}
}
}
</script>
Loading…
Cancel
Save