-
-
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.
Browse files
Browse the repository at this point in the history
render server bindings
- Loading branch information
Showing
36 changed files
with
520 additions
and
201 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
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
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
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
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 |
---|---|---|
@@ -1,43 +1,48 @@ | ||
export default { | ||
data: { | ||
count: 42 | ||
count: 42, | ||
}, | ||
|
||
html: ` | ||
<input type='number'> | ||
<input type=number> | ||
<p>number 42</p> | ||
`, | ||
|
||
test ( assert, component, target, window ) { | ||
const input = target.querySelector( 'input' ); | ||
assert.equal( input.value, '42' ); | ||
ssrHtml: ` | ||
<input type=number value=42> | ||
<p>number 42</p> | ||
`, | ||
|
||
const event = new window.Event( 'input' ); | ||
test(assert, component, target, window) { | ||
const input = target.querySelector('input'); | ||
assert.equal(input.value, '42'); | ||
|
||
const event = new window.Event('input'); | ||
|
||
input.value = '43'; | ||
input.dispatchEvent( event ); | ||
input.dispatchEvent(event); | ||
|
||
assert.equal( component.get().count, 43 ); | ||
assert.htmlEqual( target.innerHTML, ` | ||
assert.equal(component.get().count, 43); | ||
assert.htmlEqual(target.innerHTML, ` | ||
<input type='number'> | ||
<p>number 43</p> | ||
` ); | ||
`); | ||
|
||
component.set({ count: 44 }); | ||
assert.equal( input.value, '44' ); | ||
assert.htmlEqual( target.innerHTML, ` | ||
assert.equal(input.value, '44'); | ||
assert.htmlEqual(target.innerHTML, ` | ||
<input type='number'> | ||
<p>number 44</p> | ||
` ); | ||
`); | ||
|
||
// empty string should be treated as undefined | ||
input.value = ''; | ||
input.dispatchEvent( event ); | ||
input.dispatchEvent(event); | ||
|
||
assert.equal( component.get().count, undefined ); | ||
assert.htmlEqual( target.innerHTML, ` | ||
assert.equal(component.get().count, undefined); | ||
assert.htmlEqual(target.innerHTML, ` | ||
<input type='number'> | ||
<p>undefined undefined</p> | ||
` ); | ||
} | ||
`); | ||
}, | ||
}; |
33 changes: 19 additions & 14 deletions
33
test/runtime/samples/binding-input-range-change/_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 |
---|---|---|
@@ -1,33 +1,38 @@ | ||
export default { | ||
data: { | ||
count: 42 | ||
count: 42, | ||
}, | ||
|
||
html: ` | ||
<input type='range'> | ||
<input type=range> | ||
<p>number 42</p> | ||
`, | ||
|
||
test ( assert, component, target, window ) { | ||
const input = target.querySelector( 'input' ); | ||
assert.equal( input.value, '42' ); | ||
ssrHtml: ` | ||
<input type=range value=42> | ||
<p>number 42</p> | ||
`, | ||
|
||
const event = new window.Event( 'change' ); | ||
test(assert, component, target, window) { | ||
const input = target.querySelector('input'); | ||
assert.equal(input.value, '42'); | ||
|
||
const event = new window.Event('change'); | ||
|
||
input.value = '43'; | ||
input.dispatchEvent( event ); | ||
input.dispatchEvent(event); | ||
|
||
assert.equal( component.get().count, 43 ); | ||
assert.htmlEqual( target.innerHTML, ` | ||
assert.equal(component.get().count, 43); | ||
assert.htmlEqual(target.innerHTML, ` | ||
<input type='range'> | ||
<p>number 43</p> | ||
` ); | ||
`); | ||
|
||
component.set({ count: 44 }); | ||
assert.equal( input.value, '44' ); | ||
assert.htmlEqual( target.innerHTML, ` | ||
assert.equal(input.value, '44'); | ||
assert.htmlEqual(target.innerHTML, ` | ||
<input type='range'> | ||
<p>number 44</p> | ||
` ); | ||
} | ||
`); | ||
}, | ||
}; |
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 |
---|---|---|
@@ -1,33 +1,38 @@ | ||
export default { | ||
data: { | ||
count: 42 | ||
count: 42, | ||
}, | ||
|
||
html: ` | ||
<input type='range'> | ||
<input type=range> | ||
<p>number 42</p> | ||
`, | ||
|
||
test ( assert, component, target, window ) { | ||
const input = target.querySelector( 'input' ); | ||
assert.equal( input.value, '42' ); | ||
ssrHtml: ` | ||
<input type=range value=42> | ||
<p>number 42</p> | ||
`, | ||
|
||
const event = new window.Event( 'input' ); | ||
test(assert, component, target, window) { | ||
const input = target.querySelector('input'); | ||
assert.equal(input.value, '42'); | ||
|
||
const event = new window.Event('input'); | ||
|
||
input.value = '43'; | ||
input.dispatchEvent( event ); | ||
input.dispatchEvent(event); | ||
|
||
assert.equal( component.get().count, 43 ); | ||
assert.htmlEqual( target.innerHTML, ` | ||
assert.equal(component.get().count, 43); | ||
assert.htmlEqual(target.innerHTML, ` | ||
<input type='range'> | ||
<p>number 43</p> | ||
` ); | ||
`); | ||
|
||
component.set({ count: 44 }); | ||
assert.equal( input.value, '44' ); | ||
assert.htmlEqual( target.innerHTML, ` | ||
assert.equal(input.value, '44'); | ||
assert.htmlEqual(target.innerHTML, ` | ||
<input type='range'> | ||
<p>number 44</p> | ||
` ); | ||
} | ||
`); | ||
}, | ||
}; |
72 changes: 56 additions & 16 deletions
72
test/runtime/samples/binding-input-text-contextual/_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 |
---|---|---|
@@ -1,29 +1,69 @@ | ||
export default { | ||
data: { | ||
items: [ | ||
'one', | ||
'two', | ||
'three' | ||
] | ||
items: ['one', 'two', 'three'], | ||
}, | ||
html: `<div><input><p>one</p></div><div><input><p>two</p></div><div><input><p>three</p></div><!---->`, | ||
test ( assert, component, target, window ) { | ||
const inputs = [ ...target.querySelectorAll( 'input' ) ]; | ||
|
||
html: ` | ||
<div> | ||
<input><p>one</p> | ||
</div> | ||
<div> | ||
<input><p>two</p> | ||
</div> | ||
<div> | ||
<input><p>three</p> | ||
</div> | ||
`, | ||
|
||
ssrHtml: ` | ||
<div> | ||
<input value=one><p>one</p> | ||
</div> | ||
<div> | ||
<input value=two><p>two</p> | ||
</div> | ||
<div> | ||
<input value=three><p>three</p> | ||
</div> | ||
`, | ||
|
||
test(assert, component, target, window) { | ||
const inputs = [...target.querySelectorAll('input')]; | ||
const items = component.get().items; | ||
const event = new window.Event( 'input' ); | ||
const event = new window.Event('input'); | ||
|
||
assert.equal( inputs[0].value, 'one' ); | ||
assert.equal(inputs[0].value, 'one'); | ||
|
||
inputs[1].value = 'four'; | ||
inputs[1].dispatchEvent( event ); | ||
inputs[1].dispatchEvent(event); | ||
|
||
assert.equal( items[1], 'four' ); | ||
assert.equal( target.innerHTML, `<div><input><p>one</p></div><div><input><p>four</p></div><div><input><p>three</p></div><!---->` ); | ||
assert.equal(items[1], 'four'); | ||
assert.htmlEqual(target.innerHTML, ` | ||
<div> | ||
<input><p>one</p> | ||
</div> | ||
<div> | ||
<input><p>four</p> | ||
</div> | ||
<div> | ||
<input><p>three</p> | ||
</div> | ||
`); | ||
|
||
items[2] = 'five'; | ||
|
||
component.set({ items }); | ||
assert.equal( inputs[2].value, 'five' ); | ||
assert.equal( target.innerHTML, `<div><input><p>one</p></div><div><input><p>four</p></div><div><input><p>five</p></div><!---->` ); | ||
} | ||
assert.equal(inputs[2].value, 'five'); | ||
assert.htmlEqual(target.innerHTML, ` | ||
<div> | ||
<input><p>one</p> | ||
</div> | ||
<div> | ||
<input><p>four</p> | ||
</div> | ||
<div> | ||
<input><p>five</p> | ||
</div> | ||
`); | ||
}, | ||
}; |
33 changes: 19 additions & 14 deletions
33
test/runtime/samples/binding-input-text-deconflicted/_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 |
---|---|---|
@@ -1,35 +1,40 @@ | ||
export default { | ||
data: { | ||
component: { | ||
name: 'world' | ||
} | ||
name: 'world', | ||
}, | ||
}, | ||
|
||
html: ` | ||
<h1>Hello world!</h1> | ||
<input> | ||
`, | ||
|
||
test ( assert, component, target, window ) { | ||
const input = target.querySelector( 'input' ); | ||
assert.equal( input.value, 'world' ); | ||
ssrHtml: ` | ||
<h1>Hello world!</h1> | ||
<input value=world> | ||
`, | ||
|
||
const event = new window.Event( 'input' ); | ||
test(assert, component, target, window) { | ||
const input = target.querySelector('input'); | ||
assert.equal(input.value, 'world'); | ||
|
||
const event = new window.Event('input'); | ||
|
||
input.value = 'everybody'; | ||
input.dispatchEvent( event ); | ||
input.dispatchEvent(event); | ||
|
||
assert.equal( input.value, 'everybody' ); | ||
assert.htmlEqual( target.innerHTML, ` | ||
assert.equal(input.value, 'everybody'); | ||
assert.htmlEqual(target.innerHTML, ` | ||
<h1>Hello everybody!</h1> | ||
<input> | ||
` ); | ||
`); | ||
|
||
component.set({ component: { name: 'goodbye' } }); | ||
assert.equal( input.value, 'goodbye' ); | ||
assert.htmlEqual( target.innerHTML, ` | ||
assert.equal(input.value, 'goodbye'); | ||
assert.htmlEqual(target.innerHTML, ` | ||
<h1>Hello goodbye!</h1> | ||
<input> | ||
` ); | ||
} | ||
`); | ||
}, | ||
}; |
Oops, something went wrong.