diff --git a/src/common.js b/src/common.js index 205b577d3e..56acb54a7e 100644 --- a/src/common.js +++ b/src/common.js @@ -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 { diff --git a/src/sao.js b/src/sao.js index f197509227..7b31ae7fb8 100644 --- a/src/sao.js +++ b/src/sao.js @@ -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 || '')); };