From 51ae99b5eb9038b6564386e6ccf8991b91ee962b Mon Sep 17 00:00:00 2001 From: Godfrey Chan Date: Thu, 21 Nov 2024 18:14:17 -0800 Subject: [PATCH] [CLEANUP] remove branching for pre-Octane optional feature This was deprecated and removed in 4.0, which is now the minimum supported version. --- addon/src/setup-application-context.ts | 9 +---- addon/src/setup-rendering-context.ts | 14 +------ .../unit/setup-rendering-context-test.js | 39 +++++-------------- 3 files changed, 12 insertions(+), 50 deletions(-) diff --git a/addon/src/setup-application-context.ts b/addon/src/setup-application-context.ts index 40f3adfca..3857e19c8 100644 --- a/addon/src/setup-application-context.ts +++ b/addon/src/setup-application-context.ts @@ -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'; @@ -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(() => { diff --git a/addon/src/setup-rendering-context.ts b/addon/src/setup-rendering-context.ts index d2581d75d..7663c436d 100644 --- a/addon/src/setup-rendering-context.ts +++ b/addon/src/setup-rendering-context.ts @@ -1,6 +1,5 @@ import { run } from '@ember/runloop'; import Ember from 'ember'; -import global from './global.ts'; import { type BaseContext, type TestContext, @@ -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, }); diff --git a/test-app/tests/unit/setup-rendering-context-test.js b/test-app/tests/unit/setup-rendering-context-test.js index cd16fb953..2e545fb14 100644 --- a/test-app/tests/unit/setup-rendering-context-test.js +++ b/test-app/tests/unit/setup-rendering-context-test.js @@ -1,4 +1,3 @@ -/* globals EmberENV */ import { module, test } from 'qunit'; import Service from '@ember/service'; import Component, { setComponentTemplate } from '@ember/component'; @@ -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`

Hello!

`); - - 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`

Hello!

`); + await render(hbs`

Hello!

`); - assert.equal(this.element.textContent, 'Hello!'); - }); - } + assert.equal(this.element.textContent, 'Hello!'); + }); test('is settled after rendering', async function (assert) { await render(hbs`Hi!`);