Fix browser compatibilities by adding some polyfills
Chrome doesn't support Array.concat so we must use the instance method. review1108003
This commit is contained in:
+2
-2
@@ -1340,12 +1340,12 @@
|
||||
if (this.is_leaf(domain)) {
|
||||
return [domain];
|
||||
} else if (domoperator === undefined) {
|
||||
return [domain_type].concat(Array.concat.apply([],
|
||||
return [domain_type].concat([].concat.apply([],
|
||||
domain.map(function(e) {
|
||||
return this.merge(e, domain_type);
|
||||
}.bind(this))));
|
||||
} else if (domain_type == domoperator) {
|
||||
return Array.concat.apply([], domain.map(function(e) {
|
||||
return [].concat.apply([], domain.map(function(e) {
|
||||
return this.merge(e, domain_type);
|
||||
}.bind(this)));
|
||||
} else {
|
||||
|
||||
+31
@@ -5,6 +5,37 @@ var Sao = {};
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
// Browser compatibility: polyfill
|
||||
if (!('contains' in String.prototype)) {
|
||||
String.prototype.contains = function(str, startIndex) {
|
||||
return -1 !== String.prototype.indexOf.call(this, str, startIndex);
|
||||
};
|
||||
}
|
||||
if (!String.prototype.startsWith) {
|
||||
Object.defineProperty(String.prototype, 'startsWith', {
|
||||
enumerable: false,
|
||||
configurable: false,
|
||||
writable: false,
|
||||
value: function(searchString, position) {
|
||||
position = position || 0;
|
||||
return this.indexOf(searchString, position) === position;
|
||||
}
|
||||
});
|
||||
}
|
||||
if (!String.prototype.endsWith) {
|
||||
Object.defineProperty(String.prototype, 'endsWith', {
|
||||
enumerable: false,
|
||||
configurable: false,
|
||||
writable: false,
|
||||
value: function(searchString, position) {
|
||||
position = position || this.length;
|
||||
position = position - searchString.length;
|
||||
var lastIndex = this.lastIndexOf(searchString);
|
||||
return lastIndex !== -1 && lastIndex === position;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Sao.error = function(title, message) {
|
||||
alert(title + '\n' + (message || ''));
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user