TypeError: Attempted to assign to readonly propert

2019-01-26 06:04发布

问题:

Hi this page on my site works fine on desktop browser, but has a weird bug on iOS8 Safari:

The index template doesn't show up, and there's a error in the console:

TypeError: Attempted to assign to readonly property.

and it points to the following line:

}), e("rsvp/promise/all", ["../utils", "exports"], function(e, t) {
    "use strict";
    var r = e.isArray, n = e.isNonThenable;
    t["default"] = function(e, t) {
        var i = this;
        return new i(function(t, a) {
            function o(e) {
                return function(r) {
                    c[e] = r, 0===--u && t(c)
                }
            }
            function s(e) {
                u = 0, a(e)
            }
            if (!r(e))
                throw new TypeError("You must pass an array to all.");
            var l, u = e.length, c = new Array(u);
            if (0 === u) // This is the line with error
                return void t(c);
            for (var h = 0; h < e.length; h++)
                l = e[h], n(l) ? (c[h] = l, 0===--u && t(c)) : i.cast(l).then(o(h), s)
        }, t)
    }
}), e("rsvp/promise/cast", ["exports"], function(e) {
    "use strict";

Is it a known bug to mobile safari, is there fix of it?

回答1:

Maintainer of RSVP here, sorry that you ran into this issue.

Firstly, it appears you are using an older version of RSVP. I would recommend upgrading.

Unfortunately it appears this issue may be related to https://github.com/emberjs/ember.js/pull/5629 which appears to just be that JSC for non-64bit devices running iOS 8 is just broken when in 'use strict' mode. In my observations it only happens in specific situations and then only when the code in question has become optimized.

Again I am unsure if upgrading will help you, but you should consider it regardless. Additionally, if the problem persists removing all use strict statements may be the best option.

If no solution appears soon, I will likely publish an update to RSVP with the use strict statements removed.



回答2:

Have you tried to remove all the "use strict";'s from your code? From my understanding it only seems to occur with 3. generation iPads.