-
Notifications
You must be signed in to change notification settings - Fork 191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement {{#-in-element
API.
#331
Conversation
👏 |
this.elementStack.push(element); | ||
|
||
this.nextSibling = null; | ||
this.nextSiblingStack.push(null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can make this configurable for bonus points, which would allow inserting into the middle of an element 😉
but we can do it as a follow-up.
// But how do you know? | ||
|
||
// {{#-with-element "zomg"}} <-- you'll get a string back here, now what? | ||
let reference = vm.frame.getOperand<Simple.Element>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For future readers: this is unsafe but we decided to punt on error-ing since this is still experimental
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should probably remove those comments tho :P
rerender(); | ||
|
||
equalsElement(externalElement, 'div', {}, `${initialContent}[Yippie!]`); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we test setting the element to null
as part of the steps here to ensure we aren't removing the initial content?
} | ||
); | ||
|
||
equalsElement(externalElement, 'div', {}, stripTight``); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert destroyed === 0
equalsElement(externalElement, 'div', {}, stripTight``); | ||
|
||
set(view, 'showExternal', true); | ||
rerender(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert destroyed === 0
246f30d
to
ad19235
Compare
Updated based on review feedback. Should be ready for another review... |
Very excited to have a supported API for wormhole and similar behavior! Thanks guys! |
* Fix failing tests when using ember with glimmer2. * Access DOM helper using a method that is safe for both pre-glimmer2 and glimmer2. * Wrap the renderedMobiledoc documentFragment in a wrapper div (necessary for glimmer2 teardown, see glimmerjs/glimmer-vm#331 and yapplabs/ember-wormhole#66 (comment)) * Fixes #18. * Update travis node version. * Update package keywords and description.
This API (which is not used by Glimmer itself) is intended to allow the host environment to provide "wormhole" like behavior.
Specifically, when invoked
{{#-in-element
accepts an Element (that conforms to theSimple.Element
interface) and renders the block provided into that element.contents are cleared and recreated in the new location.
skip rendering the block.
in-element
block to be removed (i.e. when inside an{{#if
) the contents that were written to the foreign element arecleared.