0
0
mirror of https://github.com/sveltejs/svelte.git synced 2024-12-01 17:30:59 +01:00

Merge branch 'master' into gh-7

This commit is contained in:
Rich-Harris 2017-04-30 08:27:38 -04:00
commit 7f76ab24f9
13 changed files with 70 additions and 13 deletions

View File

@ -1,5 +1,11 @@
# Svelte changelog
## 1.18.2
* Parenthesize if-block conditions ([#532](https://github.com/sveltejs/svelte/issues/532))
* Fix parsing of parenthesized expressions ([#534](https://github.com/sveltejs/svelte/issues/534))
* Fix error on `bind:checked` that doesn't belong to a checkbox input ([#529](https://github.com/sveltejs/svelte/pull/529))
## 1.18.1
* Allow `destroy()` in event handlers ([#523](https://github.com/sveltejs/svelte/issues/523))

View File

@ -1,6 +1,6 @@
{
"name": "svelte",
"version": "1.18.1",
"version": "1.18.2",
"description": "The magical disappearing UI framework",
"main": "compiler/svelte.js",
"files": [

View File

@ -70,7 +70,7 @@ export default function visitIfBlock ( generator, block, state, node ) {
function simple ( generator, block, state, node, branch, dynamic, { name, anchor, params } ) {
block.builders.create.addBlock( deindent`
var ${name} = ${branch.condition} && ${branch.block}( ${params}, ${block.component} );
var ${name} = (${branch.condition}) && ${branch.block}( ${params}, ${block.component} );
` );
const isToplevel = !state.parentNode;
@ -169,4 +169,4 @@ function compound ( generator, block, state, node, branches, dynamic, { name, an
}
` );
}
}
}

View File

@ -34,7 +34,7 @@ export default function readExpression ( parser ) {
parser.index = start;
try {
const node = parseExpressionAt( parser.template, parser.index );
const node = parseExpressionAt( parser.template, parser.index, { preserveParens: true } );
parser.index = node.end;
return node;

View File

@ -99,4 +99,4 @@ function getType ( validator, node ) {
function list ( items, conjunction = 'or' ) {
if ( items.length === 1 ) return items[0];
return `${items.slice( 0, -1 ).join( ', ' )} ${conjunction} ${items[ items.length - 1 ]}`;
}
}

View File

@ -3,7 +3,7 @@ import { appendNode, assign, createComment, createElement, createText, detachNod
function create_main_fragment ( state, component ) {
var if_block_anchor = createComment();
var if_block = state.foo && create_if_block( state, component );
var if_block = (state.foo) && create_if_block( state, component );
return {
mount: function ( target, anchor ) {
@ -90,4 +90,4 @@ SvelteComponent.prototype.teardown = SvelteComponent.prototype.destroy = functio
this._torndown = true;
};
export default SvelteComponent;
export default SvelteComponent;

View File

@ -3,7 +3,7 @@ import { appendNode, assign, createComment, createElement, createText, detachNod
function create_main_fragment ( state, component ) {
var div = createElement( 'div' );
var if_block = state.a && create_if_block( state, component );
var if_block = (state.a) && create_if_block( state, component );
if ( if_block ) if_block.mount( div, null );
var text = createText( "\n\n\t" );
@ -13,13 +13,13 @@ function create_main_fragment ( state, component ) {
appendNode( createText( "this can be used as an anchor" ), p );
appendNode( createText( "\n\n\t" ), div );
var if_block_1 = state.b && create_if_block_1( state, component );
var if_block_1 = (state.b) && create_if_block_1( state, component );
if ( if_block_1 ) if_block_1.mount( div, null );
var text_3 = createText( "\n\n\t" );
appendNode( text_3, div );
var if_block_2 = state.c && create_if_block_2( state, component );
var if_block_2 = (state.c) && create_if_block_2( state, component );
if ( if_block_2 ) if_block_2.mount( div, null );
var text_4 = createText( "\n\n\t" );
@ -29,7 +29,7 @@ function create_main_fragment ( state, component ) {
appendNode( createText( "so can this" ), p_1 );
appendNode( createText( "\n\n\t" ), div );
var if_block_3 = state.d && create_if_block_3( state, component );
var if_block_3 = (state.d) && create_if_block_3( state, component );
if ( if_block_3 ) if_block_3.mount( div, null );
var text_7 = createText( "\n\n\t" );
@ -37,7 +37,7 @@ function create_main_fragment ( state, component ) {
var text_8 = createText( "\n\n" );
var if_block_4_anchor = createComment();
var if_block_4 = state.e && create_if_block_4( state, component );
var if_block_4 = (state.e) && create_if_block_4( state, component );
return {
mount: function ( target, anchor ) {
@ -240,4 +240,4 @@ SvelteComponent.prototype.teardown = SvelteComponent.prototype.destroy = functio
this._torndown = true;
};
export default SvelteComponent;
export default SvelteComponent;

View File

@ -0,0 +1,15 @@
export default {
data: {
a: true,
b: false
},
html: '<p>i am visible</p>',
test ( assert, component, target ) {
component.set({ a: false });
assert.htmlEqual( target.innerHTML, '' );
component.set({ b: true });
assert.htmlEqual( target.innerHTML, '<p>i am visible</p>' );
}
};

View File

@ -0,0 +1,3 @@
{{#if a || b}}
<p>i am visible</p>
{{/if}}

View File

@ -0,0 +1,16 @@
export default {
data: {
a: 'foo',
b: true,
c: [ 1, 2, 3 ],
},
html: `
<span>foo</span>
<span class="foo"></span>
<span>true</span>
<span>1</span>
<span>2</span>
<span>3</span>
`
};

View File

@ -0,0 +1,8 @@
<span>{{ (a) }}</span>
<span class='{{ (a) }}'></span>
{{#if (b) }}
<span>true</span>
{{/if}}
{{#each (c) as x}}
<span>{{x}}</span>
{{/each}}

View File

@ -0,0 +1,8 @@
[{
"message": "'checked' binding can only be used with <input type=\"checkbox\">",
"loc": {
"line": 1,
"column": 7
},
"pos": 7
}]

View File

@ -0,0 +1 @@
<input bind:checked='foo'>