Skip to content

Commit

Permalink
[CLEANUP] remove branching for pre-Octane optional feature
Browse files Browse the repository at this point in the history
This was deprecated and removed in 4.0, which is now the minimum
supported version.
  • Loading branch information
chancancode committed Nov 22, 2024
1 parent cbbadbe commit 51ae99b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 50 deletions.
9 changes: 1 addition & 8 deletions addon/src/setup-application-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
isTestContext,
type TestContext,
} from './setup-context.ts';
import global from './global.ts';
import hasEmberVersion from './has-ember-version.ts';
import settled from './settled.ts';
import getTestMetadata from './test-metadata.ts';
Expand Down Expand Up @@ -168,13 +167,7 @@ export function visit(
return visitResult;
})
.then(() => {
if (global.EmberENV._APPLICATION_TEMPLATE_WRAPPER !== false) {
context.element = document.querySelector(
'#ember-testing > .ember-view',
);
} else {
context.element = document.querySelector('#ember-testing');
}
context.element = document.querySelector('#ember-testing');
})
.then(settled)
.then(() => {
Expand Down
14 changes: 1 addition & 13 deletions addon/src/setup-rendering-context.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { run } from '@ember/runloop';
import Ember from 'ember';
import global from './global.ts';
import {
type BaseContext,
type TestContext,
Expand Down Expand Up @@ -315,18 +314,7 @@ export default function setupRenderingContext(
Object.defineProperty(renderingContext, 'element', {
configurable: true,
enumerable: true,
// ensure the element is based on the wrapping toplevel view
// Ember still wraps the main application template with a
// normal tagged view
//
// In older Ember versions (2.4) the element itself is not stable,
// and therefore we cannot update the `this.element` until after the
// rendering is completed
value:
global.EmberENV._APPLICATION_TEMPLATE_WRAPPER !== false
? getRootElement().querySelector('.ember-view')
: getRootElement(),

value: getRootElement(),
writable: false,
});

Expand Down
39 changes: 10 additions & 29 deletions test-app/tests/unit/setup-rendering-context-test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* globals EmberENV */
import { module, test } from 'qunit';
import Service from '@ember/service';
import Component, { setComponentTemplate } from '@ember/component';
Expand Down Expand Up @@ -137,36 +136,18 @@ module('setupRenderingContext', function (hooks) {
assert.equal(this.element.textContent, 'hello!');
});

if (EmberENV._APPLICATION_TEMPLATE_WRAPPER !== false) {
test('render exposes an `.element` property with application template wrapper', async function (assert) {
let rootElement = document.getElementById('ember-testing');
assert.notEqual(
this.element,
rootElement,
'this.element should not be rootElement'
);
assert.ok(
rootElement.contains(this.element),
'this.element is _within_ the rootElement'
);
await render(hbs`<p>Hello!</p>`);

assert.equal(this.element.textContent, 'Hello!');
});
} else {
test('render exposes an `.element` property without an application template wrapper', async function (assert) {
let rootElement = document.getElementById('ember-testing');
assert.equal(
this.element,
rootElement,
'this.element should _be_ rootElement'
);
test('render exposes an `.element` property without an application template wrapper', async function (assert) {
let rootElement = document.getElementById('ember-testing');
assert.equal(
this.element,
rootElement,
'this.element should _be_ rootElement'
);

await render(hbs`<p>Hello!</p>`);
await render(hbs`<p>Hello!</p>`);

assert.equal(this.element.textContent, 'Hello!');
});
}
assert.equal(this.element.textContent, 'Hello!');
});

test('is settled after rendering', async function (assert) {
await render(hbs`Hi!`);
Expand Down

0 comments on commit 51ae99b

Please sign in to comment.