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

issue on IE11 #62

Closed
pkra opened this issue Oct 23, 2017 · 12 comments
Closed

issue on IE11 #62

pkra opened this issue Oct 23, 2017 · 12 comments

Comments

@pkra
Copy link
Contributor

pkra commented Oct 23, 2017

The downcompiling example at https://github.com/mathjax/mathjax-v3/wiki/A-first-usable-demo-(using-webpack) does not work on IE11.

@pkra
Copy link
Contributor Author

pkra commented Oct 23, 2017

SCRIPT5009: 'Symbol' is undefined

@pkra pkra self-assigned this Oct 23, 2017
@pkra pkra changed the title Downcompile instructions for IE11 issue on IE11 Oct 26, 2017
@pkra
Copy link
Contributor Author

pkra commented Oct 26, 2017

I went a bit further. Since it's not really in the same direction, I've renamed the issue.

Regarding Symbol, this seems expected behavior:

Please note that this requires a native Symbol.iterator or Symbol.iterator shim at runtime for any non-array values.
https://github.com/Microsoft/TypeScript/wiki/What's-new-in-TypeScript#new---downleveliteration

Adding the babel polyfill gets me Symbol (obviously) so using the babel loader with es2015 in webpack would workaround this. (IIUC Symbol.iterator cannot be shimmed correctly in generality.)

Next I run into the following:

HTMLNodes.prototype.node = function (type, def, children) {
        if (def === void 0) { def = {}; }
        if (children === void 0) { children = []; }
        var node = this.document.createElement(type);
// ERROR Unable to get property 'createElement' of undefined or null reference
        this.setProperties(node, def);
        try {
            for (var children_1 = __values(children), children_1_1 = children_1.next(); !children_1_1.done; children_1_1 = children_1.next()) {
                var child = children_1_1.value;
                node.appendChild(child);
            }
        }

and if I hack those to the global document, I run into an error with documentStyleSheet (at which point I gave up).

@dpvc
Copy link
Member

dpvc commented Oct 26, 2017

The issue with document may be because of how your initial test.js file references the DOM document. The contents of the test file seem to be put into a function with "use strict"; in the final webpacked version, which I believe may restrict the use of global variables. Try changing

const html = MathJax.document(document, {

to

const html = MathJax.document(window.document, {

instead. Or import DOM from utils/DOM.js and use

const html = MathJax.document(DOM.document, {

See if one of those does the trick.

@pkra
Copy link
Contributor Author

pkra commented Oct 26, 2017

Thanks, Davide. I'll test it.

@pkra
Copy link
Contributor Author

pkra commented Oct 26, 2017

I screwed up earlier and accidentally tested the TeX input (which has a whole other set of problems).

For the MathML input, the polyfill gets things up an running.

However, I get Math Processing error on all three elements - data-mjx-error="Can't call method on undefined".

So that's a step forward, I suppose.

@pkra
Copy link
Contributor Author

pkra commented Oct 26, 2017

Let's continue F2F later.

@pkra
Copy link
Contributor Author

pkra commented Oct 27, 2017

As requested during the last meeting, here's a hopefully sufficient demo for the IE11 math processing error problem.

IE11-demo.zip

Quick guide to re-build:

  • put the files in a folder
  • add/link to a copy of mathjax-v3 in a ./v3subfolder (or change mmlpage.js to point to the right place)
    • I used the stretchy-cells branch
  • $ npm install wepback babel-loader babel-core babel-preset-env
  • $ npx webpack
  • Open the HTML file in the E11+Win7 VM from https://developer.microsoft.com/en-us/microsoft-edge/tools/vms/
  • see Math Processing Errors

Note: the HTML page also loads the babel polyfill from cdnjs; this can probably be done more efficiently and/or at build time.

@dpvc
Copy link
Member

dpvc commented Oct 27, 2017

Thanks, I'll take a look at it this weekend.

@dpvc
Copy link
Member

dpvc commented Oct 29, 2017

OK, it turns out that the issue is that, in IE11, the MathML elements don't have the classList property that HTML elements do (and the MathML elements do in other browsers), and so the places that MathJax uses Array.from(node.classList) in the MathML input jax fail for IE11. For IE11, one has to use node.getAttributes('class').split(/ /) to get the array, and when I change to that, the example works as expected. I'll look to see if there is any place else that this would affect things.

The output worked fine in IE11 and IE10 emulation, but two of the three equations caused output errors for IE9. I'll have to look into that further.

@pkra
Copy link
Contributor Author

pkra commented Oct 30, 2017

in IE11, the MathML elements don't have the classList property that HTML elements do

holy cow, that's terrible. (FYI same for SVG elements, https://caniuse.com/#search=classlist)

Any chance we could somehow polyfill this on IE11 (we'd need a polyfill for IE9 as well).

@dpvc
Copy link
Member

dpvc commented Nov 2, 2017

Any chance we could somehow polyfill this on IE11 (we'd need a polyfill for IE9 as well).

The classList is only used in a couple of places, so I think we can certainly add a method that uses classList when it is available, and the other approach when it isn't. So yes, we can work it out without too much trouble.

@pkra
Copy link
Contributor Author

pkra commented Nov 2, 2017

https://github.com/eligrey/classList.js might be worth looking at (as it detects partial implementations).

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