From 07357ed691575a70be9b0d23fc3891c65d156efa Mon Sep 17 00:00:00 2001 From: Chris Garrett Date: Tue, 26 Jan 2021 15:45:26 -0800 Subject: [PATCH] [DEPRECATION] Deprecates old browser support policy * Adds the deprecation specified in https://github.com/emberjs/rfcs/blob/master/text/0685-new-browser-support-policy.md * Updates the test harness to avoid failing CI for deprecations issued on IE11 --- lib/index.js | 6 ++++++ .../-internals/browser-environment/index.ts | 5 +++++ packages/ember/index.js | 16 ++++++++++++++++ tests/index.html | 8 +++++++- 4 files changed, 34 insertions(+), 1 deletion(-) diff --git a/lib/index.js b/lib/index.js index 866bb7fed7c..5e747132c6c 100644 --- a/lib/index.js +++ b/lib/index.js @@ -246,6 +246,12 @@ module.exports = { let ember; let targets = (this.project && this.project.targets && this.project.targets.browsers) || []; + if (targets.includes('ie 11')) { + this.ui.writeWarnLine( + 'Internet Explorer 11 is listed in your compilation targets, but it will no longer be supported in the next major version of Ember. Please update your targets to remove IE 11 and include new targets that are within the updated support policy. For details on the new browser support policy, see:\n\n - The official documentation: http://emberjs.com/browser-support\n - the deprecation guide: https://emberjs.com/deprecations/v3.x#toc_3-0-browser-support-policy\n' + ); + } + const isProduction = process.env.EMBER_ENV === 'production'; if ( diff --git a/packages/@ember/-internals/browser-environment/index.ts b/packages/@ember/-internals/browser-environment/index.ts index b4122c67d15..29bb5ed3154 100644 --- a/packages/@ember/-internals/browser-environment/index.ts +++ b/packages/@ember/-internals/browser-environment/index.ts @@ -3,6 +3,8 @@ import hasDom from './lib/has-dom'; declare const InstallTrigger: unknown; declare const chrome: unknown; declare const opera: unknown; +declare const MSInputMethodContext: unknown; +declare const documentMode: unknown; export { default as hasDOM } from './lib/has-dom'; export const window = hasDom ? self : null; @@ -11,3 +13,6 @@ export const history = hasDom ? self.history : null; export const userAgent = hasDom ? self.navigator.userAgent : 'Lynx (textmode)'; export const isChrome = hasDom ? typeof chrome === 'object' && !(typeof opera === 'object') : false; export const isFirefox = hasDom ? typeof InstallTrigger !== 'undefined' : false; +export const isIE = hasDom + ? typeof MSInputMethodContext !== 'undefined' && typeof documentMode !== 'undefined' + : false; diff --git a/packages/ember/index.js b/packages/ember/index.js index 24dff7aeccf..4522eb0b5e6 100644 --- a/packages/ember/index.js +++ b/packages/ember/index.js @@ -170,6 +170,22 @@ import { const Ember = (typeof context.imports.Ember === 'object' && context.imports.Ember) || {}; +import { isIE } from '@ember/-internals/browser-environment'; + +deprecate( + 'Internet Explorer 11 will no longer be supported in the next major version of Ember. For details on the new browser support policy, see the official documentation: http://emberjs.com/browser-support', + !isIE, + { + id: '3-0-browser-support-policy', + url: 'https://emberjs.com/deprecations/v3.x#toc_3-0-browser-support-policy', + until: '4.0.0', + for: 'ember-source', + since: { + enabled: '3.26.0', + }, + } +); + Ember.isNamespace = true; Ember.toString = function () { return 'Ember'; diff --git a/tests/index.html b/tests/index.html index 75d60d93bc4..57bf6b6b84d 100644 --- a/tests/index.html +++ b/tests/index.html @@ -66,7 +66,13 @@ EmberENV.ENABLE_OPTIONAL_FEATURES = true; } - EmberENV['RAISE_ON_DEPRECATION'] = true; + var isIE = Boolean(window.MSInputMethodContext) && Boolean(document.documentMode); + + // ignore deprecations for IE11 specifically (due to browser support + // policy deprecation, which happens before we can `expectDeprecation`) + if (!isIE) { + EmberENV['RAISE_ON_DEPRECATION'] = true; + } if (QUnit.urlParams.debugrendertree) { EmberENV['_DEBUG_RENDER_TREE'] = true;