Refactor to public APIs for head/tail#54
Conversation
addon/components/ember-wormhole.js
Outdated
| this._didInsert = true; | ||
| run.schedule('afterRender', () => { | ||
| // read the values from the ember-wormhole-placeholder helpers | ||
| this._firstNode = this.get('registry.head'); |
There was a problem hiding this comment.
what is the registry thing solving?
There was a problem hiding this comment.
Nevermind, it is because this is before children are rendered, is there no hook on didCreateElement? I thought there was, anyway, I don't think this should be generic and use slots. Not only because this isn't very JIT friendly but because it is confusing like it is some general feature.
There was a problem hiding this comment.
didInsertElement is not fired for Fastboot. We kind of want a "fire all hooks I know what I'm doing" mode for Fastboot rendering. Doesn't seem likely. So instead we emulate the timing of didInsertElement using the hooks that do fire.
Regarding slots you suggest this should use an array instead? Would pre-defining the shape also be sufficient?
init() {
this._super(...arguments);
this.wormholeNodeRegistry = { head: null, tail: null };
},There was a problem hiding this comment.
cool, refactored away from this.
ce9c73f to
2fb4b96
Compare
|
Another pass at the implementation here for review. @krisselden I did not refactor The ember-try config here is updated, perhaps travis needs a cache flush. I'll flesh out the docs changes later today. |
|
@mixonic I cleared the Travis cache and rekicked the build. |
|
@mixonic Ah, the travis.yml needs to be updated. |
79d484d to
0f156ac
Compare
|
This is pretty wrapped up- @bantic can you please confirm with your fastboot demo app that this PR functions correctly? I'm actually quite curious what will happen upon initial re-render of the page. The idea for fastboot users might be that the nodes inside that part of the page are destroyed and re-rendered. But we should know what is happening for sure. |
|
@mixonic Yeah, this works great with the demo app I was testing. |
|
Nice work on this, all. Thanks for driving the implementation@mixonic! I'm +1 on merging and releasing 0.4.0 assuming @chrislopresto is as well. |
|
Pushed the demo app to Heroku: https://ember-wormhole-fastboot-demo.herokuapp.com/ |
| @@ -0,0 +1,3 @@ | |||
| {{ember-wormhole-placeholder (unbound _firstNode) ~}} | |||
| {{yield ~}} | |||
| {{ember-wormhole-placeholder (unbound _lastNode) ~}} | |||
There was a problem hiding this comment.
@mixonic With the disclaimer that I haven't fastboot-ed, can you explain how this differs from:
If these approaches are functionally equivalent, we could ditch the placeholder helper (and rename _firstNode and _lastNode to something more expressive).
2af706c to
b01f5e6
Compare
Generate placeholder nodes in the `ember-wormhole` component and use the `unbound` helper in its template to place those nodes before and after userland yielded content. The wormhole component then uses these placeholders to move its contents to the target element. Also adds public documentation that `destinationElement` can be passed directly instead of `to` with a string element ID. * [breaking] Raise minimum required version to 1.13 * Note fastboot compat in README.md * Document destinationElement
b01f5e6 to
36ee4fd
Compare
|
Onward! |
In the template for ember-wormhole, use helpers that register an element to the parent wormhole component. The wormhole component can then use those elements to move to the target. This lessens the private APIs used by wormhole, but still uses private APIs to access the DOM or Fastboot SimpleDOM based on where the code is running. This could use all private API if we made SimpleDOM a dependency, but that would just inflate the JS payload with little benefit.
This unblocks Fastboot rendering. It will also mean dropping support for Ember versions before 1.13. See #47 for discussion.
TODO:
isDestroyedin theafterRendercallback.destinationElementDocument subclassing of the wormhole component classskipping this, but after merge and release I will open an issue/PR on the x-favicon repo