I'm about to release a plugin, but currently have problems with a PolyFill in Internet Explorer. My frontend of the plugin works with a JavaScript Model driven state management [MobX](https://github.com/mobxjs/mobx). It depends on an ES6 function [`Array.prototype.find`](https://github.com/paulmillr/Array.prototype.find). This polyfill is described as follow in Jira core:
module-key = 'jira.webresources:find-polyfill'
location = '/static/lib/polyfills/find/find-polyfill.js'
When I have a look at the content of that file the polyfill is incorrect:
if (!Array.prototype.find) {
Object.defineProperty(Array.prototype, 'find', { value: function(predicate) {
// 1. Let O be ? ToObject(this value).
if (this == null) {
throw new TypeError('"this" is null or not defined');
}
var o = Object(this);
// 2. Let len be ? ToLength(? Get(O, "length")).
var len = o.length >>> 0;
// 3. If IsCallable(predicate) is false, throw a TypeError exception.
if (typeof predicate !== 'function') {
throw new TypeError('predicate must be a function');
}
// 4. If thisArg was supplied, let T be thisArg; else let T be undefined.
var thisArg = arguments[1];
// 5. Let k be 0.
var k = 0;
// 6. Repeat, while k < len
while (k < len) {
// a. Let Pk be ! ToString(k).
// b. Let kValue be ? Get(O, Pk).
// c. Let testResult be ToBoolean(? Call(predicate, T, kValue, k, O )).
// d. If testResult is true, return kValue.
var kValue = o[k];
if (predicate.call(thisArg, kValue, k, o)) {
return kValue;
}
// e. Increase k by 1. k++;
}
// 7. Return undefined.
return undefined;
}
});
}
According to the community, I quote the erroneous behavior:
[...] by the spec, `Array.prototype.find` descriptor should be `{writable: true, enumerable: false, configurable: true}` and `core-js` use it. [...] - zloirock
Is there any possibility to:
- Change the system file /static/lib/polyfills/find/find-polyfill.js?
- Load a web resource before the jira.webresources:find-polyfill resource so I can hook with the correct polyfill?
- Override the web resource via atlassian-plugin.xml?
The correct implementation of the polyfill is described here: https://github.com/mobxjs/mobx/issues/1028#issuecomment-378940977
This is a duplicate post of https://stackoverflow.com/questions/54721948/jira-plugin-override-system-file
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.