Skip to content

Instantly share code, notes, and snippets.

@ldong
Last active March 2, 2017 00:17
Show Gist options
  • Save ldong/59f06e90e95bdbc3a979849e18007141 to your computer and use it in GitHub Desktop.
Save ldong/59f06e90e95bdbc3a979849e18007141 to your computer and use it in GitHub Desktop.

Question

Why would ember append application.hbs to the document.body?

First paragraph states of Ember Doc

By default, your application will render the application template and attach it to the document's body element.

But why, though?

Source code diggs

packages/ember-routing/lib/system/router.js
325:      instance.didCreateRootView(this._toplevelView);

|
v

packages/ember-application/lib/system/application-instance.js
    didCreateRootView: function (view) {
      view.appendTo(this.rootElement);
    },

|
v

packages/ember-application/lib/system/application-instance.js
89:    Overrides the base `EngineInstance._bootSync` method with concerns relevant
102:  _bootSync(options) {

|
v

packages/ember-views/lib/mixins/view_support.js
237:  appendTo(selector) {
  appendTo(selector) {
    let env = this._environment || environment;
    let target;
|
v

packages/ember-glimmer/lib/renderer.js
178:  appendTo(view, target) {

|
v
https://github.com/emberjs/ember.js/blob/v2.7.1/packages/ember-htmlbars/lib/renderer.js#L132
// This entry point is called from top-level `view.appendTo`.
Renderer.prototype.appendTo = function Renderer_appendTo(view, target) {
  var morph = this._dom.appendMorph(target);
  morph.ownerNode = morph;
  view._willInsert = true;
  _emberMetalRun_loop.default.schedule('render', this, this.renderTopLevelView, view, morph);
};

Reference

  1. Customizing the rootElement | How To Ember
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment