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

chore: remove Map polyfill since we will target ES6 #759

Merged
merged 1 commit into from
May 6, 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
183 changes: 67 additions & 116 deletions slick.core.js
Original file line number Diff line number Diff line change
Expand Up @@ -684,55 +684,6 @@
};
}

/***
* Polyfill for Map to support old browsers but
* benefit of the Map speed in modern browsers.
* @class Map
* @constructor
*/
var Map = 'Map' in window ? window.Map : function Map() {
var data = {};

/***
* Gets the item with the given key from the map or undefined if
* the map does not contain the item.
* @method get
* @param key {Map} The key of the item in the map.
*/
this.get = function(key) {
return data[key];
};

/***
* Adds or updates the item with the given key in the map.
* @method set
* @param key The key of the item in the map.
* @param value The value to insert into the map of the item in the map.
*/
this.set = function(key, value) {
data[key] = value;
};

/***
* Gets a value indicating whether the given key is present in the map.
* @method has
* @param key The key of the item in the map.
* @return {Boolean}
*/
this.has = function(key) {
return key in data;
};

/***
* Removes the item with the given key from the map.
* @method delete
* @param key The key of the item in the map.
*/
this.delete = function(key) {
delete data[key];
};
};

function regexSanitizer(dirtyHtml) {
return dirtyHtml.replace(/(\b)(on[a-z]+)(\s*)=|javascript:([^>]*)[^>]*|(<\s*)(\/*)script([<>]*).*(<\s*)(\/*)script(>*)|(&lt;)(\/*)(script|script defer)(.*)(&gt;|&gt;">)/gi, '');
}
Expand Down Expand Up @@ -1086,7 +1037,6 @@
"EventData": EventData,
"EventHandler": EventHandler,
"Range": Range,
"Map": Map,
"NonDataRow": NonDataItem,
"Group": Group,
"GroupTotals": GroupTotals,
Expand Down Expand Up @@ -1137,73 +1087,74 @@
}
}
},
/***
* A global singleton editor lock.
* @class GlobalEditorLock
* @static
* @constructor
*/
"GlobalEditorLock": new EditorLock(),
"TreeColumns": TreeColumns,

"keyCode": {
SPACE: 8,
BACKSPACE: 8,
DELETE: 46,
DOWN: 40,
END: 35,
ENTER: 13,
ESCAPE: 27,
HOME: 36,
INSERT: 45,
LEFT: 37,
PAGE_DOWN: 34,
PAGE_UP: 33,
RIGHT: 39,
TAB: 9,
UP: 38,
A: 65
},
"preClickClassName" : "slick-edit-preclick",

"GridAutosizeColsMode": {
None: 'NOA',
LegacyOff: 'LOF',
LegacyForceFit: 'LFF',
IgnoreViewport: 'IGV',
FitColsToViewport: 'FCV',
FitViewportToCols: 'FVC'
},

"ColAutosizeMode": {
Locked: 'LCK',
Guide: 'GUI',
Content: 'CON',
ContentExpandOnly: 'CXO',
ContentIntelligent: 'CTI'
},

"RowSelectionMode": {
FirstRow: 'FS1',
FirstNRows: 'FSN',
AllRows: 'ALL',
LastRow: 'LS1'
},

"ValueFilterMode": {
None: 'NONE',
DeDuplicate: 'DEDP',
GetGreatestAndSub: 'GR8T',
GetLongestTextAndSub: 'LNSB',
GetLongestText: 'LNSC'
},

"WidthEvalMode": {
Auto: 'AUTO',
TextOnly: 'CANV',
HTML: 'HTML'
}

/***
* A global singleton editor lock.
* @class GlobalEditorLock
* @static
* @constructor
*/
"GlobalEditorLock": new EditorLock(),
"TreeColumns": TreeColumns,

"keyCode": {
SPACE: 8,
BACKSPACE: 8,
DELETE: 46,
DOWN: 40,
END: 35,
ENTER: 13,
ESCAPE: 27,
HOME: 36,
INSERT: 45,
LEFT: 37,
PAGE_DOWN: 34,
PAGE_UP: 33,
RIGHT: 39,
TAB: 9,
UP: 38,
A: 65
},
"preClickClassName": "slick-edit-preclick",

"GridAutosizeColsMode": {
None: 'NOA',
LegacyOff: 'LOF',
LegacyForceFit: 'LFF',
IgnoreViewport: 'IGV',
FitColsToViewport: 'FCV',
FitViewportToCols: 'FVC'
},

"ColAutosizeMode": {
Locked: 'LCK',
Guide: 'GUI',
Content: 'CON',
ContentExpandOnly: 'CXO',
ContentIntelligent: 'CTI'
},

"RowSelectionMode": {
FirstRow: 'FS1',
FirstNRows: 'FSN',
AllRows: 'ALL',
LastRow: 'LS1'
},

"ValueFilterMode": {
None: 'NONE',
DeDuplicate: 'DEDP',
GetGreatestAndSub: 'GR8T',
GetLongestTextAndSub: 'LNSB',
GetLongestText: 'LNSC'
},

"WidthEvalMode": {
Auto: 'AUTO',
TextOnly: 'CANV',
HTML: 'HTML'
}
}

/* eslint-disable no-undef */
// also add to global object when exist
Expand Down
12 changes: 6 additions & 6 deletions slick.dataview.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
var idProperty = "id"; // property holding a unique row id
var items = []; // data by index
var rows = []; // data by row
var idxById = new Slick.Map(); // indexes by id
var idxById = new Map(); // indexes by id
var rowsById = null; // rows by id; lazy-calculated
var filter = null; // filter function
var updated = null; // updated item ids
var suspend = false; // suspends the recalculation
var isBulkSuspend = false; // delays various operations like the
// index update and delete to efficient
// versions at endUpdate
var bulkDeleteIds = new Slick.Map();
var bulkDeleteIds = new Map();
var sortAsc = true;
var fastSortField;
var sortComparer;
Expand Down Expand Up @@ -169,7 +169,7 @@
// inserted in the cleanup loop above.
items.length = newIdx;
// and finally cleanup the deleted ids to start cleanly on the next update.
bulkDeleteIds = new Slick.Map();
bulkDeleteIds = new Map();
}

function updateIdxById(startingIndex) {
Expand Down Expand Up @@ -214,7 +214,7 @@
}
items = filteredItems = data;
onSetItemsCalled.notify({ idProperty: objectIdProperty, itemCount: items.length }, null, self);
idxById = new Slick.Map();
idxById = new Map();
updateIdxById();
ensureIdUniqueness();
refresh();
Expand Down Expand Up @@ -253,7 +253,7 @@
if (ascending === false) {
items.reverse();
}
idxById = new Slick.Map();
idxById = new Map();
updateIdxById();
refresh();
}
Expand Down Expand Up @@ -281,7 +281,7 @@
if (ascending === false) {
items.reverse();
}
idxById = new Slick.Map();
idxById = new Map();
updateIdxById();
refresh();
}
Expand Down