Skip to content
This repository has been archived by the owner on Dec 14, 2021. It is now read-only.

trying to set read-only property #140

Open
terion-name opened this issue Dec 19, 2017 · 5 comments
Open

trying to set read-only property #140

terion-name opened this issue Dec 19, 2017 · 5 comments

Comments

@terion-name
Copy link

terion-name commented Dec 19, 2017

document.head = document.getElementsByTagName('head')[0];

this breaks mobile safari in ios9 with trying to set read-only property

@terion-name terion-name changed the title trying to access read-only property trying to set read-only property Dec 19, 2017
@inexorabletash
Copy link
Owner

What version of Safari are you seeing this in? I was trying Safari 9 via BrowserStack and was not able to reproduce the problem.

If you're able to come up with an alternate test I can replace what's there:

if (!('head' in document))
    document.head = document.getElementsByTagName('head')[0];

You could try if (typeof document.head !== 'object')

@terion-name
Copy link
Author

What version of Safari are you seeing this in?

Mobile safari on iOS9, that is written in issue. You can't change it's version in iOS

@terion-name
Copy link
Author

While this is really strange, because calling this from console does not triggers an error. But in real app it fails.
Maybe polyfill is loading before document.head is ready to use? Sort of document loading lifecycle...

@inexorabletash
Copy link
Owner

I'm having no luck reproducing on iOS9 / Safari 9.0.1. Can you please provide a link to a page demonstrating the problem? Or can you attempt to minimize the repro?

For example, the following runs without error on iOS9 (via BrowserStack):

<script>
if (!('head' in document)) {
  document.write('adding head');
  document.head = document.getElementsByTagName('head')[0];
}
document.write('ok: ' + navigator.userAgent);
</script>

Note that "adding head" isn't written, so the !('head' in document) test is returning false. Somehow in your configuration that test must be returning true, indicating there's either some behavior difference in the BrowserStack virtual machine configuration or that your app has some other script modifying the state of things, or... something else.

@inexorabletash
Copy link
Owner

Ping - any luck producing a stand-alone repro?

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

No branches or pull requests

2 participants