Commit c877f63b authored by JC Brand's avatar JC Brand

polyfill startsWith, to make the tests pass.

parent cf429117
...@@ -964,6 +964,7 @@ ...@@ -964,6 +964,7 @@
converse.connection._dataRecv(test_utils.createRequest(features_stanza)); converse.connection._dataRecv(test_utils.createRequest(features_stanza));
var view = converse.chatboxviews.get('coven@chat.shakespeare.lit'); var view = converse.chatboxviews.get('coven@chat.shakespeare.lit');
expect(view.model.get('features_fetched')).toBe(true);
expect(view.model.get('passwordprotected')).toBe(true); expect(view.model.get('passwordprotected')).toBe(true);
expect(view.model.get('hidden')).toBe(true); expect(view.model.get('hidden')).toBe(true);
expect(view.model.get('temporary')).toBe(true); expect(view.model.get('temporary')).toBe(true);
......
if (!String.prototype.endsWith) { if (!String.prototype.endsWith) {
String.prototype.endsWith = function(searchString, position) { String.prototype.endsWith = function (searchString, position) {
var subjectString = this.toString(); var subjectString = this.toString();
if (position === undefined || position > subjectString.length) { if (position === undefined || position > subjectString.length) {
position = subjectString.length; position = subjectString.length;
...@@ -10,10 +10,19 @@ if (!String.prototype.endsWith) { ...@@ -10,10 +10,19 @@ if (!String.prototype.endsWith) {
}; };
} }
String.prototype.splitOnce = function (delimiter) { if (!String.prototype.startsWith) {
var components = this.split(delimiter); String.prototype.startsWith = function (searchString, position) {
return [components.shift(), components.join(delimiter)]; position = position || 0;
}; return this.substr(position, searchString.length) === searchString;
};
}
if (!String.prototype.splitOnce) {
String.prototype.splitOnce = function (delimiter) {
var components = this.split(delimiter);
return [components.shift(), components.join(delimiter)];
};
}
if (!String.prototype.trim) { if (!String.prototype.trim) {
String.prototype.trim = function () { String.prototype.trim = function () {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment