Skip to content
This repository has been archived by the owner on Dec 4, 2019. It is now read-only.

IE10 compatibility fix #261

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
8 changes: 4 additions & 4 deletions src/components/body/StyleTranslator.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export class StyleTranslator{

constructor(height){
this.height = height;
this.map = new Map();
this.map = {};
}

/**
Expand All @@ -17,8 +17,8 @@ export class StyleTranslator{
*/
update(rows){
let n = 0;
while (n <= this.map.size) {
let dom = this.map.get(n);
while (n <= Object.keys(this.map).length) {
let dom = this.map[n];
let model = rows[n];
if(dom && model){
TranslateXY(dom[0].style, 0, model.$$index * this.height);
Expand All @@ -33,7 +33,7 @@ export class StyleTranslator{
* @param {dom} dom
*/
register(idx, dom){
this.map.set(idx, dom);
this.map[idx] = dom;
}

}
109 changes: 81 additions & 28 deletions src/utils/polyfill.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,91 @@
/**
* Array.prototype.find()
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find
*/
(function() {
function polyfill(fnName) {
if (!Array.prototype[fnName]) {
Array.prototype[fnName] = function(predicate /*, thisArg */ ) {
var i, len, test, thisArg = arguments[1];

if (typeof predicate !== "function") {
throw new TypeError();
(function () {
/**
* Array.prototype.find()
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find
*/
if (!Array.prototype.find) {
Object.defineProperty(Array.prototype, 'find', {
value: function (predicate) {
'use strict';
if (this == null) {
throw new TypeError('Array.prototype.find called on null or undefined');
}
if (typeof predicate !== 'function') {
throw new TypeError('predicate must be a function');
}
var list = Object(this);
var length = list.length >>> 0;
var thisArg = arguments[1];
var value;

test = !thisArg ? predicate : function() {
return predicate.apply(thisArg, arguments);
};

for (i = 0, len = this.length; i < len; i++) {
if (test(this[i], i, this) === true) {
return fnName === "find" ? this[i] : i;
for (var i = 0; i < length; i++) {
value = list[i];
if (predicate.call(thisArg, value, i, list)) {
return value;
}
}
return undefined;
}
});
}
/**
* Array.prototype.findIndex()
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex
*/
if (!Array.prototype.findIndex) {
Object.defineProperty(Array.prototype, 'findIndex', {
value: function (predicate) {
'use strict';
if (this == null) {
throw new TypeError('Array.prototype.findIndex called on null or undefined');
}
if (typeof predicate !== 'function') {
throw new TypeError('predicate must be a function');
}
var list = Object(this);
var length = list.length >>> 0;
var thisArg = arguments[1];
var value;

if (fnName !== "find") {
return -1;
for (var i = 0; i < length; i++) {
value = list[i];
if (predicate.call(thisArg, value, i, list)) {
return i;
}
}
};
}
return -1;
},
enumerable: false,
configurable: false,
writable: false
});
}
/**
* Object.assign()
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
*/
if (typeof Object.assign != 'function') {
Object.assign = function (target, varArgs) { // .length of function is 2
'use strict';
if (target == null) { // TypeError if undefined or null
throw new TypeError('Cannot convert undefined or null to object');
}

var to = Object(target);

for (var index = 1; index < arguments.length; index++) {
var nextSource = arguments[index];

for (var i in {
find: 1,
findIndex: 1
}) {
polyfill(i);
if (nextSource != null) { // Skip over if undefined or null
for (var nextKey in nextSource) {
// Avoid bugs when hasOwnProperty is shadowed
if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {
to[nextKey] = nextSource[nextKey];
}
}
}
}
return to;
};
}
}());