make html validators work inside else blocks

pull/226/head
Arpad Borsos 9 years ago
parent 5801df8a25
commit 91551b9d43
No known key found for this signature in database
GPG Key ID: 908EDF65263368B4

@ -23,6 +23,10 @@ export default function validateHtml ( validator, html ) {
node.children.forEach( visit );
}
if (node.else ) {
visit( node.else );
}
if ( node.type === 'Element' ) {
elementDepth -= 1;
}

@ -38,11 +38,13 @@ describe( 'validate', () => {
const expectedErrors = tryToLoadJson( `test/validator/${dir}/errors.json` ) || [];
const expectedWarnings = tryToLoadJson( `test/validator/${dir}/warnings.json` ) || [];
const expectedNames = tryToLoadJson( `test/validator/${dir}/names.json` ) || [];
const expectedNames = tryToLoadJson( `test/validator/${dir}/names.json` );
assert.deepEqual( errors, expectedErrors );
assert.deepEqual( warnings, expectedWarnings );
assert.deepEqual( names, expectedNames );
if ( expectedNames ) {
assert.deepEqual( names, expectedNames );
}
} catch ( err ) {
if ( err.name !== 'ParseError' ) throw err;

@ -1,3 +1,27 @@
{{#each things as thing, index}}
<p>{{index}}: {{thing}}</p>
{{else}}
{{#each things as thingEachElse, indexEachElse}}
<p>{{indexEachElse}}: {{thingEachElse}}</p>
{{/each}}
{{/each}}
{{#if foo}}
{{elseif bar}}
{{#each things as thingIfElse, indexIfElse}}
<p>{{indexIfElse}}: {{thingIfElse}}</p>
{{/each}}
{{else}}
{{#each things as thingElse, indexElse}}
<p>{{indexElse}}: {{thingElse}}</p>
{{/each}}
{{/if}}

@ -1,4 +1,10 @@
[
"thing",
"index"
"index",
"thingEachElse",
"indexEachElse",
"thingIfElse",
"indexIfElse",
"thingElse",
"indexElse"
]

@ -1 +1,29 @@
<rect x='{{x}}' y='{{y}}' width='{{width}}' height='{{height}}'/>
{{#each foo as bar}}
<rect x='{{x}}' y='{{y}}' width='{{width}}' height='{{height}}'/>
{{else}}
{{#each foo as bar}}
<rect x='{{x}}' y='{{y}}' width='{{width}}' height='{{height}}'/>
{{/each}}
{{/each}}
{{#if foo}}
{{elseif bar}}
{{#each foo as bar}}
<rect x='{{x}}' y='{{y}}' width='{{width}}' height='{{height}}'/>
{{/each}}
{{else}}
{{#each foo as bar}}
<rect x='{{x}}' y='{{y}}' width='{{width}}' height='{{height}}'/>
{{/each}}
{{/if}}

@ -5,4 +5,36 @@
"column": 0
},
"pos": 0
},
{
"message": "<rect> is an SVG element did you forget to add { namespace: 'svg' } ?",
"loc": {
"column": 1,
"line": 5
},
"pos": 90
},
{
"message": "<rect> is an SVG element did you forget to add { namespace: 'svg' } ?",
"loc": {
"column": 2,
"line": 10
},
"pos": 191
},
{
"message": "<rect> is an SVG element did you forget to add { namespace: 'svg' } ?",
"loc": {
"column": 2,
"line": 20
},
"pos": 333
},
{
"message": "<rect> is an SVG element did you forget to add { namespace: 'svg' } ?",
"loc": {
"column": 2,
"line": 26
},
"pos": 445
}]

Loading…
Cancel
Save