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

Core: IE11 workaround for currentScript #2104

Merged
merged 6 commits into from
Oct 25, 2019

Conversation

RunDevelopment
Copy link
Member

@RunDevelopment RunDevelopment commented Oct 24, 2019

This fixes #2102.

The IE11 workaround was inspired by this.

@BrainStone
Copy link

Are you sure #2103 needs fixing and not #2102? ;)

@RunDevelopment
Copy link
Member Author

Thanks for pointing that out 😅

@RunDevelopment RunDevelopment merged commit 2108c60 into PrismJS:master Oct 25, 2019
@RunDevelopment RunDevelopment deleted the core-current-script branch October 25, 2019 15:34
@muenzpraeger
Copy link

Hey - I wanted to use Prism embedded into a web component, but ran into the issue that this IE11 hack is used. Specifically it is that in my environment scripts[i] can be undefined.

Any thoughts on accepting a PR that extends the if check on undefined? Happy to put that in.

@RunDevelopment
Copy link
Member Author

@muenzpraeger How can scripts[i] be undefined? scripts is a HTMLCollection, so iterating with for in should iterate over all indexes.

@muenzpraeger
Copy link

It runs within a secure context of that environment.

@RunDevelopment
Copy link
Member Author

Ok, after a dive into the documentation, I found the issue. The "global" document object is a mock object that is an instance of the SecureDocument interface (class?). This explains why the currentScript property is absent (it's listed as "not supported") but it doesn't explain why getElementsByTagName doesn't return an HTMLCollection since the function is listed as supported since v46.

My conclusion is that this is a bug with SecureDocument. The getElementsByTagName function is supposed to return a value that fulfills the HTMLCollection interface but it doesn't. Please report this bug, so the authors of SecureDocument can fix it.

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

Successfully merging this pull request may close these issues.

Defer breaks autoload (when loading page without having resources cached)
4 participants