Skip to content

Commit

Permalink
Remove workarounds for IE/old edge
Browse files Browse the repository at this point in the history
  • Loading branch information
dfahlander committed Feb 8, 2024
1 parent a86f874 commit ef13479
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 22 deletions.
3 changes: 1 addition & 2 deletions src/classes/collection/collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { rejection } from "../../helpers/promise";
import { combine } from "../../functions/combine";
import { extend, hasOwn, deepClone, keys, setByKeyPath, getByKeyPath } from "../../functions/utils";
import { ModifyError } from "../../errors";
import { hangsOnDeleteLargeKeyRange } from "../../globals/constants";
import { ThenShortcut } from "../../public/types/then-shortcut";
import { Transaction } from '../transaction';
import { DBCoreCursor, DBCoreTransaction, DBCoreRangeType, DBCoreMutateResponse, DBCoreKeyRange } from '../../public/types/dbcore';
Expand Down Expand Up @@ -594,7 +593,7 @@ export class Collection implements ICollection {
//deletingHook = ctx.table.hook.deleting.fire,
//hasDeleteHook = deletingHook !== nop;
if (isPlainKeyRange(ctx) &&
((ctx.isPrimKey && !hangsOnDeleteLargeKeyRange) || range.type === DBCoreRangeType.Any)) // if no range, we'll use clear().
(ctx.isPrimKey || range.type === DBCoreRangeType.Any)) // if no range, we'll use clear().
{
// May use IDBObjectStore.delete(IDBKeyRange) in this case (Issue #208)
// For chromium, this is the way most optimized version.
Expand Down
11 changes: 4 additions & 7 deletions src/classes/version/schema-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import Promise, { PSD, newScope, NativePromise, decrementExpectedAwaits, increme
import { exceptions } from '../../errors';
import { TableSchema } from '../../public/types/table-schema';
import { IndexSpec } from '../../public/types/index-spec';
import { hasIEDeleteObjectStoreBug, isIEOrEdge } from '../../globals/constants';
import { createIndexSpec, nameFromKeyPath } from '../../helpers/index-spec';
import { createTableSchema } from '../../helpers/table-schema';
import { generateMiddlewareStacks } from '../dexie/generate-middleware-stacks';
Expand Down Expand Up @@ -231,11 +230,9 @@ function updateTablesAndIndexes(
}
});
queue.push(idbtrans => {
if (!anyContentUpgraderHasRun || !hasIEDeleteObjectStoreBug) { // Dont delete old tables if ieBug is present and a content upgrader has run. Let tables be left in DB so far. This needs to be taken care of.
const newSchema = version._cfg.dbschema;
// Delete old tables
deleteRemovedTables(newSchema, idbtrans);
}
const newSchema = version._cfg.dbschema;
// Delete old tables
deleteRemovedTables(newSchema, idbtrans);
// Restore the final API
removeTablesApi(db, [db.Transaction.prototype]);
setApiOnPlace(db, [db.Transaction.prototype], db._storeNames, db._dbSchema);
Expand Down Expand Up @@ -316,7 +313,7 @@ export function getSchemaDiff(oldSchema: DbSchema, newSchema: DbSchema): SchemaD
''+(newDef.primKey.keyPath||'')
) ||
// Compare the autoIncrement flag also
(oldDef.primKey.auto !== newDef.primKey.auto && !isIEOrEdge)) // IE has bug reading autoIncrement prop.
(oldDef.primKey.auto !== newDef.primKey.auto))
{
// Primary key has changed. Remove and re-add table.
change.recreate = true;
Expand Down
4 changes: 0 additions & 4 deletions src/globals/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ export const INVALID_KEY_ARGUMENT =
"Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.";
export const STRING_EXPECTED = "String expected.";
export const connections: Dexie[] = [];
export const isIEOrEdge =
typeof navigator !== 'undefined' && /(MSIE|Trident|Edge)/.test(navigator.userAgent);
export const hasIEDeleteObjectStoreBug = isIEOrEdge;
export const hangsOnDeleteLargeKeyRange = isIEOrEdge;
export const dexieStackFrameFilter = frame => !/(dexie\.js|dexie\.min\.js)/.test(frame);
export const DBNAMES_DB = '__dbnames';
export const READONLY = 'readonly';
Expand Down
12 changes: 3 additions & 9 deletions src/live-query/propagate-locally.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { isIEOrEdge } from '../globals/constants';
import { globalEvents, DEXIE_STORAGE_MUTATED_EVENT_NAME, STORAGE_MUTATED_DOM_EVENT_NAME } from '../globals/global-events';
import { ObservabilitySet } from "../public/types/db-events";
import { signalSubscribersNow } from './cache/signalSubscribers';
Expand All @@ -7,14 +6,9 @@ if (typeof dispatchEvent !== 'undefined' && typeof addEventListener !== 'undefin
globalEvents(DEXIE_STORAGE_MUTATED_EVENT_NAME, updatedParts => {
if (!propagatingLocally) {
let event: CustomEvent<ObservabilitySet>;
if (isIEOrEdge) {
event = document.createEvent('CustomEvent');
event.initCustomEvent(STORAGE_MUTATED_DOM_EVENT_NAME, true, true, updatedParts);
} else {
event = new CustomEvent(STORAGE_MUTATED_DOM_EVENT_NAME, {
detail: updatedParts
});
}
event = new CustomEvent(STORAGE_MUTATED_DOM_EVENT_NAME, {
detail: updatedParts
});
propagatingLocally = true;
dispatchEvent(event);
propagatingLocally = false;
Expand Down

0 comments on commit ef13479

Please sign in to comment.