Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove IE11-specific code #4603

Merged
merged 2 commits into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
};

Comment on lines -209 to -236
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method (containing IE11 specific code) was not used anymore.

/**
* Three.js EventDispatcher and DOM EventTarget use different event patterns,
* so AnyEvent covers the shape of both event types.
Expand Down
Loading