diff --git a/packages/ember-application/lib/system/application-instance.js b/packages/ember-application/lib/system/application-instance.js index 54339c0c578..e7075c5cb30 100644 --- a/packages/ember-application/lib/system/application-instance.js +++ b/packages/ember-application/lib/system/application-instance.js @@ -316,173 +316,175 @@ ApplicationInstance.reopenClass({ @namespace ApplicationInstance @public */ -function BootOptions(options = {}) { - /** - Provide a specific instance of jQuery. This is useful in conjunction with - the `document` option, as it allows you to use a copy of `jQuery` that is - appropriately bound to the foreign `document` (e.g. a jsdom). - - This is highly experimental and support very incomplete at the moment. - - @property jQuery - @type Object - @default auto-detected - @private - */ - this.jQuery = jQuery; // This default is overridable below - - /** - Interactive mode: whether we need to set up event delegation and invoke - lifecycle callbacks on Components. - - @property isInteractive - @type boolean - @default auto-detected - @private - */ - this.isInteractive = environment.hasDOM; // This default is overridable below - - /** - Run in a full browser environment. - - When this flag is set to `false`, it will disable most browser-specific - and interactive features. Specifically: - - * It does not use `jQuery` to append the root view; the `rootElement` - (either specified as a subsequent option or on the application itself) - must already be an `Element` in the given `document` (as opposed to a - string selector). - - * It does not set up an `EventDispatcher`. - - * It does not run any `Component` lifecycle hooks (such as `didInsertElement`). - - * It sets the `location` option to `"none"`. (If you would like to use - the location adapter specified in the app's router instead, you can also - specify `{ location: null }` to specifically opt-out.) - - @property isBrowser - @type boolean - @default auto-detected - @public - */ - if (options.isBrowser !== undefined) { - this.isBrowser = !!options.isBrowser; - } else { - this.isBrowser = environment.hasDOM; - } - - if (!this.isBrowser) { - this.jQuery = null; - this.isInteractive = false; - this.location = 'none'; - } +class BootOptions { + constructor(options = {}) { + /** + Provide a specific instance of jQuery. This is useful in conjunction with + the `document` option, as it allows you to use a copy of `jQuery` that is + appropriately bound to the foreign `document` (e.g. a jsdom). + + This is highly experimental and support very incomplete at the moment. + + @property jQuery + @type Object + @default auto-detected + @private + */ + this.jQuery = jQuery; // This default is overridable below + + /** + Interactive mode: whether we need to set up event delegation and invoke + lifecycle callbacks on Components. + + @property isInteractive + @type boolean + @default auto-detected + @private + */ + this.isInteractive = environment.hasDOM; // This default is overridable below + + /** + Run in a full browser environment. + + When this flag is set to `false`, it will disable most browser-specific + and interactive features. Specifically: + + * It does not use `jQuery` to append the root view; the `rootElement` + (either specified as a subsequent option or on the application itself) + must already be an `Element` in the given `document` (as opposed to a + string selector). + + * It does not set up an `EventDispatcher`. + + * It does not run any `Component` lifecycle hooks (such as `didInsertElement`). + + * It sets the `location` option to `"none"`. (If you would like to use + the location adapter specified in the app's router instead, you can also + specify `{ location: null }` to specifically opt-out.) + + @property isBrowser + @type boolean + @default auto-detected + @public + */ + if (options.isBrowser !== undefined) { + this.isBrowser = !!options.isBrowser; + } else { + this.isBrowser = environment.hasDOM; + } - /** - Disable rendering completely. + if (!this.isBrowser) { + this.jQuery = null; + this.isInteractive = false; + this.location = 'none'; + } - When this flag is set to `true`, it will disable the entire rendering - pipeline. Essentially, this puts the app into "routing-only" mode. No - templates will be rendered, and no Components will be created. + /** + Disable rendering completely. - @property shouldRender - @type boolean - @default true - @public - */ - if (options.shouldRender !== undefined) { - this.shouldRender = !!options.shouldRender; - } else { - this.shouldRender = true; - } + When this flag is set to `true`, it will disable the entire rendering + pipeline. Essentially, this puts the app into "routing-only" mode. No + templates will be rendered, and no Components will be created. - if (!this.shouldRender) { - this.jQuery = null; - this.isInteractive = false; - } + @property shouldRender + @type boolean + @default true + @public + */ + if (options.shouldRender !== undefined) { + this.shouldRender = !!options.shouldRender; + } else { + this.shouldRender = true; + } - /** - If present, render into the given `Document` object instead of the - global `window.document` object. - - In practice, this is only useful in non-browser environment or in - non-interactive mode, because Ember's `jQuery` dependency is - implicitly bound to the current document, causing event delegation - to not work properly when the app is rendered into a foreign - document object (such as an iframe's `contentDocument`). - - In non-browser mode, this could be a "`Document`-like" object as - Ember only interact with a small subset of the DOM API in non- - interactive mode. While the exact requirements have not yet been - formalized, the `SimpleDOM` library's implementation is known to - work. - - @property document - @type Document - @default the global `document` object - @public - */ - if (options.document) { - this.document = options.document; - } else { - this.document = (typeof document !== 'undefined') ? document : null; - } + if (!this.shouldRender) { + this.jQuery = null; + this.isInteractive = false; + } - /** - If present, overrides the application's `rootElement` property on - the instance. This is useful for testing environment, where you - might want to append the root view to a fixture area. + /** + If present, render into the given `Document` object instead of the + global `window.document` object. + + In practice, this is only useful in non-browser environment or in + non-interactive mode, because Ember's `jQuery` dependency is + implicitly bound to the current document, causing event delegation + to not work properly when the app is rendered into a foreign + document object (such as an iframe's `contentDocument`). + + In non-browser mode, this could be a "`Document`-like" object as + Ember only interact with a small subset of the DOM API in non- + interactive mode. While the exact requirements have not yet been + formalized, the `SimpleDOM` library's implementation is known to + work. + + @property document + @type Document + @default the global `document` object + @public + */ + if (options.document) { + this.document = options.document; + } else { + this.document = (typeof document !== 'undefined') ? document : null; + } - In non-browser mode, because Ember does not have access to jQuery, - this options must be specified as a DOM `Element` object instead of - a selector string. + /** + If present, overrides the application's `rootElement` property on + the instance. This is useful for testing environment, where you + might want to append the root view to a fixture area. - See the documentation on `Application`'s `rootElement` for - details. + In non-browser mode, because Ember does not have access to jQuery, + this options must be specified as a DOM `Element` object instead of + a selector string. - @property rootElement - @type String|Element - @default null - @public - */ - if (options.rootElement) { - this.rootElement = options.rootElement; - } + See the documentation on `Application`'s `rootElement` for + details. - // Set these options last to give the user a chance to override the - // defaults from the "combo" options like `isBrowser` (although in - // practice, the resulting combination is probably invalid) + @property rootElement + @type String|Element + @default null + @public + */ + if (options.rootElement) { + this.rootElement = options.rootElement; + } - /** - If present, overrides the router's `location` property with this - value. This is useful for environments where trying to modify the - URL would be inappropriate. + // Set these options last to give the user a chance to override the + // defaults from the "combo" options like `isBrowser` (although in + // practice, the resulting combination is probably invalid) + + /** + If present, overrides the router's `location` property with this + value. This is useful for environments where trying to modify the + URL would be inappropriate. + + @property location + @type string + @default null + @public + */ + if (options.location !== undefined) { + this.location = options.location; + } - @property location - @type string - @default null - @public - */ - if (options.location !== undefined) { - this.location = options.location; - } + if (options.jQuery !== undefined) { + this.jQuery = options.jQuery; + } - if (options.jQuery !== undefined) { - this.jQuery = options.jQuery; + if (options.isInteractive !== undefined) { + this.isInteractive = !!options.isInteractive; + } } - if (options.isInteractive !== undefined) { - this.isInteractive = !!options.isInteractive; + toEnvironment() { + let env = assign({}, environment); + // For compatibility with existing code + env.hasDOM = this.isBrowser; + env.isInteractive = this.isInteractive; + env.options = this; + return env; } } -BootOptions.prototype.toEnvironment = function() { - let env = assign({}, environment); - // For compatibility with existing code - env.hasDOM = this.isBrowser; - env.isInteractive = this.isInteractive; - env.options = this; - return env; -}; - export default ApplicationInstance;