Skip to content

Script loading/eval not working for IE8 #30

@brtubb

Description

@brtubb

It appears the script parsing of templates fails quietly in IE8. The end result is a silent failure that doesn't get emit from ractive-load in any fashion, and puts the Promise in a metastable state (never triggers fail/success criteria).

The core issue is in eval2.Function(). The code is wrapping the component's <script> with an anonymous function to achieve scope isolation. The bug manifests itself here in IE8: this older version of IE doesn't eval anonymous functions properly, returning "undefined" instead of the desired effect. There's a little more information in this SO thread: http://stackoverflow.com/q/1271516

The "solution" I'm using is further down in the answers: http://stackoverflow.com/a/8115692
Appears to be working well for me and hasn't caused other deleterious effects (yet). I'm happy to submit a PR if this looks like a reasonable fix.

var jsString = "(function(arg1) { alert('Hello World!'); })";

/*
 * IE8/9 Fails in current code
 */
eval(jsString); 
// undefined

/*
 * Suggested Solution
 */
eval("false||" + jsString);
// (function(arg1)...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions