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

iOS 8.1 Javascript error in OTFeatureInfo.js #21

Open
kontur opened this issue Mar 2, 2017 · 5 comments
Open

iOS 8.1 Javascript error in OTFeatureInfo.js #21

kontur opened this issue Mar 2, 2017 · 5 comments

Comments

@kontur
Copy link
Contributor

kontur commented Mar 2, 2017

The call to Object.freeze(https://github.com/graphicore/specimenTools/blob/master/lib/services/OTFeatureInfo.js#L775) is causing an Javascript error in iOS 8.1.

The code checks if obj is indeed of type 'object', but for this case it seems to be 'undefined' when it reaches this line.

I'm not entirely sure what is going on in this part of the code, so I thought I run this by you first.

@graphicore
Copy link
Owner

The code checks if obj is indeed of type 'object', but for this case it seems to be 'undefined' when it reaches this line.

This looks like a strange bug in the iOS JS. The objcan't change within this function. Have you tried to searching for a bug in wherever iOS 8.1 Javascript is managed. iOS 8.1 JavaScript, what is this Mobile Safari?

We could try ... catch the call and just go without freezing there. It's more like an API measure to make it explicit that the data in the module shouldn't be changed, maybe even a bit paranoid. If we don't freeze on systems we develop on, it's not changing anything.

@graphicore
Copy link
Owner

The code checks if obj is indeed of type 'object', but for this case it seems to be 'undefined' when it reaches this line.

Thinking about this, it could well be that Object.freeze is not defined in old browsers.

The error would be something like "undefined is not a function" or "TypeError: Object.freeze is not a function." the message depends on the js interpreter.

If so:

function deepFreeze(obj) {
        var k;
        if(!Object.freeze) return;
        if(typeof obj !== 'object') return;
        for(k in obj)
            deepFreeze(obj[k]);
        Object.freeze(obj);
}

this should do the trick. Could you try this out?

@kontur
Copy link
Contributor Author

kontur commented Apr 2, 2017

Funnily enough this fails not because Object.freeze is not defined (it seems to be) nor because the obj passed in would not be a an object (at least according to typeof). Very odd.

With a try-catch it can be made to not break, as per: kontur@753d5b2

However, I get another javascript error that seems to also appear only on that outdated iOS version. Here the error is undefined is not a function

@graphicore
Copy link
Owner

However, I get another javascript error that seems to also appear only on that outdated iOS version. Here the error is undefined is not a function

In this case codePointAt is probably not defined. It's a newer replacement for charCodeAt

There's a Polyfill though.

@kontur
Copy link
Contributor Author

kontur commented Apr 8, 2017

That seems to do the trick, no more iOS 8 errors at least on the test pages. I couldn't find any other places that have included a polyfill, so in this instance I included at inside the FontsData.js. I have my changes in this branch

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

No branches or pull requests

2 participants