Skip to content

Commit

Permalink
Remove application-template-wrapper optional feature support
Browse files Browse the repository at this point in the history
Since 4.0, Ember throws if you try to enable the application-template-wrapper optional feature.

This removes the remaining implementation of that (inaccessible) feature.
  • Loading branch information
ef4 committed Apr 22, 2024
1 parent a435903 commit f11de0c
Show file tree
Hide file tree
Showing 11 changed files with 3 additions and 114 deletions.
15 changes: 0 additions & 15 deletions packages/@ember/-internals/environment/lib/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,21 +66,6 @@ export const ENV = {

STRUCTURED_PROFILE: false,

/**
Whether to insert a `<div class="ember-view" />` wrapper around the
application template. See RFC #280.
This is not intended to be set directly, as the implementation may change in
the future. Use `@ember/optional-features` instead.
@property _APPLICATION_TEMPLATE_WRAPPER
@for EmberENV
@type Boolean
@default true
@private
*/
_APPLICATION_TEMPLATE_WRAPPER: true,

/**
Whether to use Glimmer Component semantics (as opposed to the classic "Curly"
components semantics) for template-only components. See RFC #278.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { ENV } from '@ember/-internals/environment';
import type { InternalOwner } from '@ember/-internals/owner';
import { guidFor } from '@ember/-internals/utils';
import { assert } from '@ember/debug';
import EngineInstance from '@ember/engine/instance';
import { _instrumentStart } from '@ember/instrumentation';
Expand All @@ -17,7 +15,6 @@ import type {
VMArguments,
WithCreateInstance,
WithCustomDebugRenderTree,
WithDynamicTagName,
} from '@glimmer/interfaces';
import type { Nullable } from '@ember/-internals/utility-types';
import { capabilityFlagsFrom } from '@glimmer/manager';
Expand All @@ -26,7 +23,6 @@ import { createConstRef, valueForRef } from '@glimmer/reference';
import { EMPTY_ARGS } from '@glimmer/runtime';
import { unwrapTemplate } from '@glimmer/util';

import type { SimpleElement } from '@simple-dom/interface';
import type { DynamicScope } from '../renderer';
import type { OutletState } from '../utils/outlet';
import type OutletView from '../views/outlet';
Expand Down Expand Up @@ -211,36 +207,5 @@ export class OutletComponentDefinition
}

export function createRootOutlet(outletView: OutletView): OutletComponentDefinition {
if (ENV._APPLICATION_TEMPLATE_WRAPPER) {
const WRAPPED_CAPABILITIES = Object.assign({}, CAPABILITIES, {
dynamicTag: true,
elementHook: true,
wrapped: true,
});

const WrappedOutletComponentManager = class
extends OutletComponentManager
implements WithDynamicTagName<OutletInstanceState>
{
getTagName() {
return 'div';
}

getCapabilities(): InternalComponentCapabilities {
return WRAPPED_CAPABILITIES;
}

didCreateElement(component: OutletInstanceState, element: SimpleElement): void {
// to add GUID id and class
element.setAttribute('class', 'ember-view');
element.setAttribute('id', guidFor(component));
}
};

const WRAPPED_OUTLET_MANAGER = new WrappedOutletComponentManager();

return new OutletComponentDefinition(outletView.state, WRAPPED_OUTLET_MANAGER);
} else {
return new OutletComponentDefinition(outletView.state);
}
return new OutletComponentDefinition(outletView.state);
}
Original file line number Diff line number Diff line change
Expand Up @@ -1637,9 +1637,7 @@ if (ENV._DEBUG_RENDER_TREE) {
args: { positional: [], named: {} },
instance: undefined,
template: outlet,
bounds: ENV._APPLICATION_TEMPLATE_WRAPPER
? this.nodeBounds(this.element)
: this.elementBounds(this.element!),
bounds: this.elementBounds(this.element!),
children: [
this.outlet({
type: 'route-template',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@ moduleFor(
class extends ApplicationTestCase {
constructor() {
super(...arguments);
this._APPLICATION_TEMPLATE_WRAPPER = ENV._APPLICATION_TEMPLATE_WRAPPER;
this._TEMPLATE_ONLY_GLIMMER_COMPONENTS = ENV._TEMPLATE_ONLY_GLIMMER_COMPONENTS;

ENV._APPLICATION_TEMPLATE_WRAPPER = false;
ENV._TEMPLATE_ONLY_GLIMMER_COMPONENTS = true;

let didCreateReloader = (reloader) => {
Expand Down Expand Up @@ -81,7 +79,6 @@ moduleFor(

teardown() {
super.teardown();
ENV._APPLICATION_TEMPLATE_WRAPPER = this._APPLICATION_TEMPLATE_WRAPPER;
ENV._TEMPLATE_ONLY_GLIMMER_COMPONENTS = this._TEMPLATE_ONLY_GLIMMER_COMPONENTS;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { moduleFor, ApplicationTestCase, strip } from 'internal-test-helpers';

import { ENV } from '@ember/-internals/environment';
import Controller from '@ember/controller';
import Route from '@ember/routing/route';
import { service } from '@ember/service';
Expand All @@ -13,29 +12,7 @@ import { runTask } from '../../../../../../internal-test-helpers/lib/run';
moduleFor(
'Application test: rendering',
class extends ApplicationTestCase {
constructor() {
super(...arguments);
this._APPLICATION_TEMPLATE_WRAPPER = ENV._APPLICATION_TEMPLATE_WRAPPER;
}

teardown() {
super.teardown();
ENV._APPLICATION_TEMPLATE_WRAPPER = this._APPLICATION_TEMPLATE_WRAPPER;
}

['@test it can render the application template with a wrapper']() {
ENV._APPLICATION_TEMPLATE_WRAPPER = true;

this.addTemplate('application', 'Hello world!');

return this.visit('/').then(() => {
this.assertComponentElement(this.element, { content: 'Hello world!' });
});
}

['@test it can render the application template without a wrapper']() {
ENV._APPLICATION_TEMPLATE_WRAPPER = false;

this.addTemplate('application', 'Hello world!');

return this.visit('/').then(() => {
Expand Down
5 changes: 0 additions & 5 deletions packages/@ember/application/tests/visit_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import Engine from '@ember/engine';
import Route from '@ember/routing/route';
import { Component, helper, isSerializationFirstNode } from '@ember/-internals/glimmer';
import { compile } from 'ember-template-compiler';
import { ENV } from '@ember/-internals/environment';

function expectAsyncError() {
RSVP.off('error');
Expand All @@ -26,7 +25,6 @@ moduleFor(
class extends ApplicationTestCase {
teardown() {
RSVP.on('error', onerrorDefault);
ENV._APPLICATION_TEMPLATE_WRAPPER = false;
super.teardown();
}

Expand All @@ -52,7 +50,6 @@ moduleFor(
rootElement,
};

ENV._APPLICATION_TEMPLATE_WRAPPER = false;
return this.visit('/', bootOptions).then(() => {
assert.equal(
rootElement.innerHTML,
Expand All @@ -75,8 +72,6 @@ moduleFor(
_renderMode: 'serialize',
};

ENV._APPLICATION_TEMPLATE_WRAPPER = false;

return this.visit('/', bootOptions)
.then((instance) => {
assert.ok(
Expand Down
22 changes: 0 additions & 22 deletions packages/ember/tests/routing/toplevel_dom_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,7 @@ import { moduleFor, ApplicationTestCase } from 'internal-test-helpers';
moduleFor(
'Top Level DOM Structure',
class extends ApplicationTestCase {
constructor() {
super(...arguments);
this._APPLICATION_TEMPLATE_WRAPPER = ENV._APPLICATION_TEMPLATE_WRAPPER;
}

teardown() {
super.teardown();
ENV._APPLICATION_TEMPLATE_WRAPPER = this._APPLICATION_TEMPLATE_WRAPPER;
}

['@test topmost template with wrapper']() {
ENV._APPLICATION_TEMPLATE_WRAPPER = true;

this.addTemplate('application', 'hello world');

return this.visit('/').then(() => {
this.assertComponentElement(this.element, { content: 'hello world' });
});
}

['@test topmost template without wrapper']() {
ENV._APPLICATION_TEMPLATE_WRAPPER = false;

this.addTemplate('application', 'hello world');

return this.visit('/').then(() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { EmberPrecompileOptions } from 'ember-template-compiler';
import { compile } from 'ember-template-compiler';
import { ENV } from '@ember/-internals/environment';
import AbstractTestCase from './abstract';
import { runDestroy, runTask, runLoopSettled } from '../run';
import type { BootOptions } from '@ember/engine/instance';
Expand Down Expand Up @@ -48,9 +47,7 @@ export default abstract class AbstractApplicationTestCase extends AbstractTestCa
return this._element;
}

let element = document.querySelector(
ENV._APPLICATION_TEMPLATE_WRAPPER ? '#qunit-fixture > div.ember-view' : '#qunit-fixture'
);
let element = document.querySelector('#qunit-fixture');

return (this._element = element);
}
Expand Down
1 change: 0 additions & 1 deletion tests/docs/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ module.exports = {
'LOG_STACKTRACE_ON_DEPRECATION',
'LOG_VERSION',
'[]',
'_APPLICATION_TEMPLATE_WRAPPER',
'_DEBUG_RENDER_TREE',
'_DEFAULT_ASYNC_OBSERVERS',
'_NO_IMPLICIT_ROUTE_MODEL',
Expand Down
1 change: 0 additions & 1 deletion tests/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@

if (edition === 'octane') {
EmberENV._TEMPLATE_ONLY_GLIMMER_COMPONENTS = true;
EmberENV._APPLICATION_TEMPLATE_WRAPPER = false;
EmberENV._DEFAULT_ASYNC_OBSERVERS = true;
}

Expand Down
1 change: 0 additions & 1 deletion tests/node/fastboot-sandbox-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ function buildSandboxContext(precompile) {
`
var EmberENV = {
_TEMPLATE_ONLY_GLIMMER_COMPONENTS: true,
_APPLICATION_TEMPLATE_WRAPPER: false,
_DEFAULT_ASYNC_OBSERVERS: true,
_JQUERY_INTEGRATION: false,
};`,
Expand Down

0 comments on commit f11de0c

Please sign in to comment.