-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Fix yield block placement
- Loading branch information
Showing
4 changed files
with
51 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
export default function visitYieldTag ( generator, block, state ) { | ||
block.builders.mount.addLine( | ||
`${block.component}._yield && ${block.component}._yield.mount( ${state.parentNode || block.target}, null );` | ||
const parentNode = state.parentNode || block.target; | ||
|
||
( state.parentNode ? block.builders.create : block.builders.mount ).addLine( | ||
`if ( ${block.component}._yield ) ${block.component}._yield.mount( ${parentNode}, null );` | ||
); | ||
|
||
block.builders.destroy.addLine( | ||
`${block.component}._yield && ${block.component}._yield.destroy( detach );` | ||
`if ( ${block.component}._yield ) ${block.component}._yield.destroy( detach );` | ||
); | ||
} |
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,6 @@ | ||
<div class='modal-background' on:click='destroy()'></div> | ||
|
||
<div class='modal'> | ||
{{yield}} | ||
<button on:click='destroy()'>close modal</button> | ||
</div> |
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,25 @@ | ||
export default { | ||
data: { | ||
showModal: true | ||
}, | ||
|
||
html: ` | ||
<div class='modal-background'></div> | ||
<div class='modal'> | ||
<h2>Hello!</h2> | ||
<button>close modal</button> | ||
</div> | ||
`, | ||
|
||
test ( assert, component, target, window ) { | ||
const button = target.querySelector( 'button' ); | ||
const click = new window.MouseEvent( 'click' ); | ||
|
||
button.dispatchEvent( click ); | ||
|
||
assert.htmlEqual( target.innerHTML, ` | ||
<button>show modal</button> | ||
`); | ||
} | ||
}; |
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,15 @@ | ||
{{#if showModal}} | ||
<Modal on:destroy='set({ showModal: false })'> | ||
<h2>Hello!</h2> | ||
</Modal> | ||
{{else}} | ||
<button on:click='set({ showModal: true })'>show modal</button> | ||
{{/if}} | ||
|
||
<script> | ||
import Modal from './Modal.html'; | ||
|
||
export default { | ||
components: { Modal } | ||
}; | ||
</script> |