Skip to content

Commit

Permalink
🚮 Remove IE Support via Polyfills and Conditional Statements (#35317)
Browse files Browse the repository at this point in the history
* Since we are not using the data, lets remove it

* Remove all isIE checks and polyfills only used by IE

* Remove URL changes

* Integration tests were looking for IE specifics

* remove transparent img, and ie tests

* Skip all tests on IE, this functionality will be removed by the infra team following success

* try using user agent directy in test configuration

* Fix

* Feedback on describe tests not needing configuration now

* Remove unused files again

* Fix build before main is repaired
  • Loading branch information
kristoferbaxter committed Aug 25, 2021
1 parent 9151bde commit 1e13253
Show file tree
Hide file tree
Showing 24 changed files with 374 additions and 1,054 deletions.
2 changes: 0 additions & 2 deletions build-system/test-configs/dep-check-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,6 @@ exports.rules = [
'3p/polyfills.js->src/polyfills/string-starts-with.js',
'src/amp.js->src/polyfills/index.js',
'src/polyfills/index.js->src/polyfills/abort-controller.js',
'src/polyfills/index.js->src/polyfills/domtokenlist.js',
'src/polyfills/index.js->src/polyfills/document-contains.js',
'src/polyfills/index.js->src/polyfills/fetch.js',
'src/polyfills/index.js->src/polyfills/get-bounding-client-rect.js',
Expand All @@ -443,7 +442,6 @@ exports.rules = [
'src/friendly-iframe-embed.js->src/polyfills/abort-controller.js',
'src/friendly-iframe-embed.js->src/polyfills/custom-elements.js',
'src/friendly-iframe-embed.js->src/polyfills/document-contains.js',
'src/friendly-iframe-embed.js->src/polyfills/domtokenlist.js',
'src/friendly-iframe-embed.js->src/polyfills/intersection-observer.js',
'src/friendly-iframe-embed.js->src/polyfills/resize-observer.js',
],
Expand Down
1 change: 0 additions & 1 deletion build-system/test-configs/forbidden-terms.js
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,6 @@ const forbiddenTermsGlobal = {
message:
'SVG data images must use charset=utf-8: ' +
'"data:image/svg+xml;charset=utf-8,..."',
allowlist: ['src/service/ie-intrinsic-bug.js'],
},
'new CustomEvent\\(': {
message: 'Use createCustomEvent() helper instead.',
Expand Down
21 changes: 0 additions & 21 deletions src/core/dom/img.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,3 @@ export function guaranteeSrcForSrcsetUnsupportedBrowsers(img) {
img.setAttribute('src', srcseturl);
}
}

/**
* Generates a transparent PNG of a given width/height.
*
* @param {!Document} doc
* @param {number} width
* @param {number} height
* @return {string}
*/
export function transparentPng(doc, width, height) {
const canvas = /** @type {!HTMLCanvasElement} */ (
doc.createElement('canvas')
);
canvas.width = width;
canvas.height = height;

// Canvases are fully transparent by default, so we don't actually need to
// draw anything.

return canvas.toDataURL();
}
5 changes: 1 addition & 4 deletions src/custom-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -1175,10 +1175,7 @@ function createBaseCustomElementClass(win, elementConnectedCallback) {
this.everAttached = true;

try {
this.layout_ = applyStaticLayout(
this,
Services.platformFor(toWin(this.ownerDocument.defaultView)).isIe()
);
this.layout_ = applyStaticLayout(this);
this.initMediaAttrs_();
} catch (e) {
reportError(e, this);
Expand Down
2 changes: 0 additions & 2 deletions src/friendly-iframe-embed.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import {toWin} from '#core/window';
import {install as installAbortController} from '#polyfills/abort-controller';
import {install as installCustomElements} from '#polyfills/custom-elements';
import {install as installDocContains} from '#polyfills/document-contains';
import {install as installDOMTokenList} from '#polyfills/domtokenlist';
import {installForChildWin as installIntersectionObserver} from '#polyfills/intersection-observer';
import {installForChildWin as installResizeObserver} from '#polyfills/resize-observer';

Expand Down Expand Up @@ -686,7 +685,6 @@ export class FriendlyIframeEmbed {
function installPolyfillsInChildWindow(parentWin, childWin) {
if (!mode.isEsm()) {
installDocContains(childWin);
installDOMTokenList(childWin);
}
// The anonymous class parameter allows us to detect native classes vs
// transpiled classes.
Expand Down
54 changes: 0 additions & 54 deletions src/polyfills/domtokenlist.js

This file was deleted.

2 changes: 0 additions & 2 deletions src/polyfills/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {install as installAbortController} from './abort-controller';
import {install as installArrayIncludes} from './array-includes';
import {install as installCustomElements} from './custom-elements';
import {install as installDocContains} from './document-contains';
import {install as installDOMTokenList} from './domtokenlist';
import {install as installFetch} from './fetch';
import {install as installGetBoundingClientRect} from './get-bounding-client-rect';
import {install as installIntersectionObserver} from './intersection-observer';
Expand Down Expand Up @@ -36,7 +35,6 @@ if (!mode.isEsm()) {
// Polyfills that depend on DOM availability
if (self.document) {
if (!mode.isEsm()) {
installDOMTokenList(self);
installDocContains(self);
installGetBoundingClientRect(self);
}
Expand Down
39 changes: 0 additions & 39 deletions src/service/ie-intrinsic-bug.js

This file was deleted.

61 changes: 0 additions & 61 deletions src/service/ie-media-bug.js

This file was deleted.

20 changes: 1 addition & 19 deletions src/service/navigation.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import {PriorityQueue} from '#core/data-structures/priority-queue';
import {isIframed, tryFocus} from '#core/dom';
import {isIframed} from '#core/dom';
import {escapeCssSelectorIdent} from '#core/dom/css-selectors';
import {closestAncestorElementBySelector} from '#core/dom/query';
import * as mode from '#core/mode';
import {dict} from '#core/types/object';
import {toWin} from '#core/window';

Expand Down Expand Up @@ -599,23 +598,6 @@ export class Navigation {
* @private
*/
handleHashNavigation_(e, toLocation, fromLocation) {
// Anchor navigation in IE doesn't change input focus, which can result in
// confusing behavior e.g. when pressing "tab" button.
// @see https://humanwhocodes.com/blog/2013/01/15/fixing-skip-to-content-links/
// @see https://github.com/ampproject/amphtml/issues/18671
if (!mode.isEsm() && Services.platformFor(this.ampdoc.win).isIe()) {
const id = toLocation.hash.substring(1);
const elementWithId = this.ampdoc.getElementById(id);
if (elementWithId) {
if (
!/^(?:a|select|input|button|textarea)$/i.test(elementWithId.tagName)
) {
elementWithId.tabIndex = -1;
}
tryFocus(elementWithId);
}
}

// We prevent default so that the current click does not push
// into the history stack as this messes up the external documents
// history which contains the amp document.
Expand Down
17 changes: 0 additions & 17 deletions src/service/platform-impl.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import * as mode from '#core/mode';

import {registerServiceBuilder} from '../service-helpers';

/**
Expand Down Expand Up @@ -42,7 +40,6 @@ export class Platform {
return (
/Safari/i.test(this.navigator_.userAgent) &&
!this.isChrome() &&
!this.isIe() &&
!this.isEdge() &&
!this.isFirefox() &&
!this.isOpera()
Expand Down Expand Up @@ -81,17 +78,6 @@ export class Platform {
return /OPR\/|Opera|OPiOS/i.test(this.navigator_.userAgent);
}

/**
* Whether the current browser is a IE browser.
* @return {boolean}
*/
isIe() {
if (mode.isEsm()) {
return false;
}
return /Trident|MSIE|IEMobile/i.test(this.navigator_.userAgent);
}

/**
* Whether the current browser is an Edge browser.
* @return {boolean}
Expand Down Expand Up @@ -155,9 +141,6 @@ export class Platform {
if (this.isOpera()) {
return this.evalMajorVersion_(/(OPR|Opera|OPiOS)\/(\d+)/, 2);
}
if (this.isIe()) {
return this.evalMajorVersion_(/MSIE\s(\d+)/, 1);
}
if (this.isEdge()) {
return this.evalMajorVersion_(/Edge\/(\d+)/, 1);
}
Expand Down
12 changes: 1 addition & 11 deletions src/service/resources-impl.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import {dict} from '#core/types/object';

import {Services} from '#service';

import {ieIntrinsicCheckAndFix} from './ie-intrinsic-bug';
import {ieMediaCheckAndFix} from './ie-media-bug';
import {Resource, ResourceState} from './resource';
import {READY_SCAN_SIGNAL, ResourcesInterface} from './resources-interface';
import {TaskQueue} from './task-queue';
Expand Down Expand Up @@ -242,16 +240,8 @@ export class ResourcesImpl {
return;
}

ieIntrinsicCheckAndFix(this.win);

const fixPromise = ieMediaCheckAndFix(this.win);
const remeasure = () => this.remeasurePass_.schedule();
if (fixPromise) {
fixPromise.then(remeasure);
} else {
// No promise means that there's no problem.
remeasure();
}
remeasure();

// Safari 10 and under incorrectly estimates font spacing for
// `@font-face` fonts. This leads to wild measurement errors. The best
Expand Down

0 comments on commit 1e13253

Please sign in to comment.