Skip to content

Commit

Permalink
Remove IE11-specific code (#4603)
Browse files Browse the repository at this point in the history
* Remove unused method

* Refactor IE11-specific code

Since IE11 is not supported anymore.
  • Loading branch information
Frank3K authored Dec 20, 2023
1 parent 99fa9a8 commit ff13ec1
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 60 deletions.
6 changes: 1 addition & 5 deletions packages/model-viewer/src/features/controls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -888,11 +888,7 @@ export const ControlsMixin = <T extends Constructor<ModelViewerElementBase>>(
};

[$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');
};
}

Expand Down
9 changes: 1 addition & 8 deletions packages/model-viewer/src/features/loading.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,14 +295,7 @@ export const LoadingMixin = <T extends Constructor<ModelViewerElementBase>>(
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);

Expand Down
8 changes: 1 addition & 7 deletions packages/model-viewer/src/styles/deserializers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,7 @@ export const enumerationDeserializer = <T extends string>(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<T>();
for (const name of names) {
result.add(name);
}
return result;
return new Set<T>(names);
} catch (_error) {
}
return new Set();
Expand Down
14 changes: 2 additions & 12 deletions packages/model-viewer/src/three-components/Hotspot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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', {
Expand Down
28 changes: 0 additions & 28 deletions packages/model-viewer/src/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = <T = any, U = any>(map: Map<T, U>): 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<T, U>) => {
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.
Expand Down

0 comments on commit ff13ec1

Please sign in to comment.