diff --git a/packages/model-viewer/src/features/controls.ts b/packages/model-viewer/src/features/controls.ts index e41daf21f7..6b9b41bb30 100644 --- a/packages/model-viewer/src/features/controls.ts +++ b/packages/model-viewer/src/features/controls.ts @@ -888,11 +888,7 @@ export const ControlsMixin = >( }; [$onPointerChange] = (event: PointerChangeEvent) => { - if (event.type === 'pointer-change-start') { - this[$container].classList.add('pointer-tumbling'); - } else { - this[$container].classList.remove('pointer-tumbling'); - } + this[$container].classList.toggle('pointer-tumbling', event.type === 'pointer-change-start'); }; } diff --git a/packages/model-viewer/src/features/loading.ts b/packages/model-viewer/src/features/loading.ts index 4b10845d47..8d2b7fafef 100644 --- a/packages/model-viewer/src/features/loading.ts +++ b/packages/model-viewer/src/features/loading.ts @@ -295,14 +295,7 @@ export const LoadingMixin = >( parentNode.appendChild(this[$defaultProgressBarElement]); } - // NOTE(cdata): IE11 does not properly respect the second parameter - // of classList.toggle, which this implementation originally used. - // @see https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/11865865/ - if (progress === 1.0) { - this[$defaultProgressBarElement].classList.add('hide'); - } else { - this[$defaultProgressBarElement].classList.remove('hide'); - } + this[$defaultProgressBarElement].classList.toggle('hide', progress === 1.0); }); }, PROGRESS_BAR_UPDATE_THRESHOLD); diff --git a/packages/model-viewer/src/styles/deserializers.ts b/packages/model-viewer/src/styles/deserializers.ts index ecf9757969..b2f403b2de 100644 --- a/packages/model-viewer/src/styles/deserializers.ts +++ b/packages/model-viewer/src/styles/deserializers.ts @@ -47,13 +47,7 @@ export const enumerationDeserializer = (allowedNames: T[]) => .map(valueNode => valueNode.value as T) .filter(name => allowedNames.indexOf(name) > -1); - // NOTE(cdata): IE11 does not support constructing a Set directly from - // an iterable, so we need to manually add all the items: - const result = new Set(); - for (const name of names) { - result.add(name); - } - return result; + return new Set(names); } catch (_error) { } return new Set(); diff --git a/packages/model-viewer/src/three-components/Hotspot.ts b/packages/model-viewer/src/three-components/Hotspot.ts index f20d7ee766..7569589867 100644 --- a/packages/model-viewer/src/three-components/Hotspot.ts +++ b/packages/model-viewer/src/three-components/Hotspot.ts @@ -175,12 +175,7 @@ export class Hotspot extends CSS2DObject { } updateVisibility(show: boolean) { - // NOTE: IE11 doesn't support a second arg for classList.toggle - if (show) { - this.element.classList.remove('hide'); - } else { - this.element.classList.add('hide'); - } + this.element.classList.toggle('hide', !show); // NOTE: ShadyDOM doesn't support slot.assignedElements, otherwise we could // use that here. @@ -196,12 +191,7 @@ export class Hotspot extends CSS2DObject { if (visibilityAttribute != null) { const attributeName = `data-${visibilityAttribute}`; - // NOTE: IE11 doesn't support toggleAttribute - if (show) { - element.setAttribute(attributeName, ''); - } else { - element.removeAttribute(attributeName); - } + element.toggleAttribute(attributeName, show); } element.dispatchEvent(new CustomEvent('hotspot-visibility', { diff --git a/packages/model-viewer/src/utilities.ts b/packages/model-viewer/src/utilities.ts index 6d937531bb..467653308a 100644 --- a/packages/model-viewer/src/utilities.ts +++ b/packages/model-viewer/src/utilities.ts @@ -206,34 +206,6 @@ export const isDebugMode = (() => { })(); -/** - * Returns the first key in a Map in iteration order. - * - * NOTE(cdata): This is necessary because IE11 does not implement iterator - * methods of Map, and polymer-build does not polyfill these methods for - * compatibility and performance reasons. This helper proposes that it is - * a reasonable compromise to sacrifice a very small amount of runtime - * performance in IE11 for the sake of code clarity. - */ -export const getFirstMapKey = (map: Map): T|null => { - if (map.keys != null) { - return map.keys().next().value || null; - } - - let firstKey: T|null = null; - - try { - map.forEach((_value: U, key: T, _map: Map) => { - firstKey = key; - // Stop iterating the Map with forEach: - throw new Error(); - }); - } catch (_error) { - } - - return firstKey; -}; - /** * Three.js EventDispatcher and DOM EventTarget use different event patterns, * so AnyEvent covers the shape of both event types.