Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Attempted to assign to readonly property. on Safari 6 (Mac) #392

Closed
federicogfernandez opened this issue Jul 30, 2012 · 13 comments
Closed
Milestone

Comments

@federicogfernandez
Copy link

@federicogfernandez federicogfernandez commented Jul 30, 2012

plugin.load(map.name, makeRequire(map.parentMap, true, function (deps, cb) {
deps.rjsSkipMap = true;
return context.require(deps, cb);
}), load, config);

At line deps.rjsSkipMap = true; it returns an error "TypeError: Attempted to assign to readonly property." and stops the load of the modules.

@jstarrdewar
Copy link

@jstarrdewar jstarrdewar commented Jul 31, 2012

It's happening to me too. It is only happening in Safari 6. No problems in Safari 5.x or Chrome. I'm using 2.0.2

@jstarrdewar
Copy link

@jstarrdewar jstarrdewar commented Jul 31, 2012

At least on my configuration, I have narrowed it down to the i18n plugin. When I remove all i18n! imports it loads fine.

@shoork
Copy link

@shoork shoork commented Jul 31, 2012

Hi... same problem here... also seems to be in i18n plugin....

@jstarrdewar
Copy link

@jstarrdewar jstarrdewar commented Jul 31, 2012

Here's the eventual load timeout error I get (my translations are in a file called 'strings.js'): Error: Load timeout for modules: i18n!nls/strings_unnormalized2,i18n!nls/strings

@jrburke
Copy link
Member

@jrburke jrburke commented Aug 1, 2012

Hmm, yes, something is up, it appears that when in 'use strict' mode, Safari 6 does not like it if I add a property to a string value. Other strict aware browsers allow the assignment but apparently give undefined when reading it back.

I'm investigating a fix, but in the meantime, if you are stuck, open up the require.js file and remove the 'use strict'; line near the top of the code.

jrburke added a commit that referenced this issue Aug 1, 2012
…d r.js removes strict statements anyway by default. More consistent behavior now.
@jrburke
Copy link
Member

@jrburke jrburke commented Aug 1, 2012

Fixed in master, just removed strict, for reasons, see commit above:

https://github.com/jrburke/requirejs/blob/master/require.js

@shoork
Copy link

@shoork shoork commented Aug 1, 2012

There is always "side effect" on my code :(

shim: {
    'backbone-min': {
        deps: ['underscore-min', 'json2'],
        exports: 'Backbone'
     }

require([
(...)
'libs/backbone/backbone-min',
], function(App){

And when i try to access to Backbone I get "ReferenceError: Can't find variable: Backbone" (only on safari 6)....
(and same problem with another module Globalize)

I will investigate today but others navs are ok :(

@jrburke
Copy link
Member

@jrburke jrburke commented Aug 1, 2012

@shoork do you get that error with the latest master require.js that has a fix for the original issue in this ticket?

https://raw.github.com/jrburke/requirejs/master/require.js

If you try the latest master that should perform better if it is caused by the same underlying issue.

@shoork
Copy link

@shoork shoork commented Aug 1, 2012

no I just make the fix "removing strict"... i'll test with lastest master this afternoon (in a few hours) to see if it solve the problem

@jrburke
Copy link
Member

@jrburke jrburke commented Aug 1, 2012

@shoork OK. If you still see the issue, then I suggest opening a new ticket, since it will likely be a different fix, and I will want to track the fix separately from this one.

@marcokrikke
Copy link

@marcokrikke marcokrikke commented Aug 4, 2012

Hi James,

Same problem here. I'm using the r.js optimiser to include two locales in a build. When loading the non-root locale in the optimised scenario, the error above occurs in Safari 6 (and on iPhone). Removing the "use strict" line does indeed fix the problem.

A minimal implementation in order to reproduce this bug can be found at:

https://github.com/marcokrikke/requirejs-strict-mode-error

Steps to reproduce:

  • deploy the project
  • index.html is the non-optimised version, works as expected
  • index_build.html will give the "TypeError: Attempted to assign to readonly property" error.
@jrburke
Copy link
Member

@jrburke jrburke commented Aug 4, 2012

@marcokrikke see one of my previous comments to a link to the requirejs master version that fixes the problem. That fix will be in a 2.0.5 release.

@marcokrikke
Copy link

@marcokrikke marcokrikke commented Aug 4, 2012

@jrburke yup, already found that one, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.