-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #384 from sveltejs/shorthand-attributes
implement :shorthand attributes
- Loading branch information
Showing
8 changed files
with
115 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
test/generator/samples/attribute-dynamic-shorthand/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export default { | ||
html: `<div id="foo"></div>`, | ||
|
||
test ( assert, component, target ) { | ||
component.set({ id: 'bar' }); | ||
assert.equal( target.innerHTML, `<div id="bar"></div>` ); | ||
|
||
component.teardown(); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<div :id/> | ||
|
||
<script> | ||
export default { | ||
data: () => ({ | ||
id: 'foo' | ||
}) | ||
}; | ||
</script> |
1 change: 1 addition & 0 deletions
1
test/generator/samples/component-data-dynamic-shorthand/Widget.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<p>foo: {{foo}}</p> |
17 changes: 17 additions & 0 deletions
17
test/generator/samples/component-data-dynamic-shorthand/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
export default { | ||
data: { | ||
foo: 42 | ||
}, | ||
|
||
html: `<div><p>foo: 42</p></div>`, | ||
|
||
test ( assert, component, target ) { | ||
component.set({ | ||
foo: 99 | ||
}); | ||
|
||
assert.equal( target.innerHTML, `<div><p>foo: 99</p></div>` ); | ||
|
||
component.teardown(); | ||
} | ||
}; |
11 changes: 11 additions & 0 deletions
11
test/generator/samples/component-data-dynamic-shorthand/main.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<div> | ||
<Widget :foo/> | ||
</div> | ||
|
||
<script> | ||
import Widget from './Widget.html'; | ||
|
||
export default { | ||
components: { Widget } | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<div :id/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{ | ||
"hash": 4120363214, | ||
"html": { | ||
"start": 0, | ||
"end": 10, | ||
"type": "Fragment", | ||
"children": [ | ||
{ | ||
"start": 0, | ||
"end": 10, | ||
"type": "Element", | ||
"name": "div", | ||
"attributes": [ | ||
{ | ||
"start": 5, | ||
"end": 8, | ||
"type": "Attribute", | ||
"name": "id", | ||
"value": [ | ||
{ | ||
"start": 6, | ||
"end": 8, | ||
"type": "AttributeShorthand", | ||
"expression": { | ||
"type": "Identifier", | ||
"start": 6, | ||
"end": 8, | ||
"name": "id" | ||
} | ||
} | ||
] | ||
} | ||
], | ||
"children": [] | ||
} | ||
] | ||
}, | ||
"css": null, | ||
"js": null | ||
} |