views:

231

answers:

2

Im getting SyntaxError: Parse Error, only on safari. Here is the code in question.

<script type="text/javascript">
$(document).ready(function() {
    $("form").transload({
        auth: {key: "b7deac9c96af6c745e914e25d0350baa"},
        flow: {
            encode: {
                "use": ":original",
                "robot": "/video/encode",
                "preset": "flash",
                "width": 480,
                "height": 320
            },
            encode_iphone: {
                "use": ":original",
                "robot": "/video/encode",
                "preset": "iphone"
            },
            export: {
                "use": ["encode","encode_iphone"],
                "robot": "/s3/store"
            }
        }
    });
});
</script>

I am using transloadit a jquery plugin. which works on every other page and is loading fine on safari by the looks of it.

The errors is on line 44 which is

export: {

Can anyone see anything wrong with that page?

+5  A: 

The word export is an ECMAScript future reserved word, in some implementations using this keywords as identifiers cause SyntaxErrors.

However you can simply use a string literal, instead the identifier:

//....
        "export": {
            "use": ["encode","encode_iphone"],
            "robot": "/s3/store"
        }
//....

This keyword may be used on the future for module declarations:

CMS
that worked great, thanks!
Josh Crowder
+2  A: 

The following words are used as keywords in proposed extensions and are therefore reserved to allow for the possibility of future adoption of those extensions.

class enum extends super const export import

ECMAScript Language Specification, section 7.6.1 Reserved Words

Other interpreters might be more liberal about them, which might explain that it only gives a SyntaxError in JavascriptCore (Safari's javascript interpreter).

Adrien Friggeri