kittykatattack / dust

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

IE & Safar Support?

mishawagon opened this issue · comments

Hello and thank you for your great work on this library.
I have one small problem: it doesn't seem to work for Safari 9. I get the error that default parameter assignment is not supported.

SyntaxError: Unexpected token '='. Expected a ')' or a ',' after a parameter declaration.
(anonymous function) — dust.js:2

It seems that default operator assignment is also not support in IE. Is dust a library for only Chrome, Firefox, and Safar >= 10? Are you aware of any cross platform particle system libraries for Pixi?

Any thoughts would be greatly appreciated.

Can you provide a reduced test case? I have no problems running the particle example from the Hexi repo on Safari 9.1.2

Hello, thank you so much for your time on this.
When I link dust from src I get the error in Safari. A zip of the code can be found here: https://drive.google.com/open?id=0ByMi53EXujAKSUpKR3FPMUtnXzA
When I link it from bin I get a different error:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Hello World</title>
    <script src="tink/src/tink.js"></script>
    <script src="dust/src/dust.js"></script>

  </head>

  <body>
    <script>
      let t = new Tink(PIXI, renderer.view);

      let d = new Dust(PIXI);
    </script>

  </body>

</html>

Errors:
[Error] SyntaxError: Unexpected token '='. Expected a ')' or a ',' after a parameter declaration.
(anonymous function) (tink.js:2)
[Error] SyntaxError: Unexpected token '='. Expected a ')' or a ',' after a parameter declaration.
(anonymous function) (dust.js:2)
[Error] SyntaxError: Unexpected identifier 't'
(anonymous function) (192.168.1.254:13)

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Hello World</title>
    <script src="tink/bin/tink.js"></script>
    <script src="dust/bin/dust.js"></script>

  </head>

  <body>
    <script>
      let t = new Tink(PIXI, renderer.view);

      let d = new Dust(PIXI);
    </script>

  </body>

</html>

[Error] ReferenceError: Can't find variable: exports
global code (dust.js:5)
[Error] SyntaxError: Unexpected identifier 't'
(anonymous function) (192.168.1.254:13)

OK so there are a few things going on here:

  1. Safari 9 does not support the let keyword so your inline script will always fail when you try to assign t using it.
  2. The src folder contains ES2015 javascript so you can't run it directly in the browser; it's meant to be compiled with babel. So no sense putting it in a script tag as your first example
  3. The exports variable error is because you're using an old version of the library that was designed to be used only as a module. If you use the current version from this repo you should be fine.

Wow, fantastic, thank you. Can you recommend a way to include it as a module?

Just use the latest version in this repo and you don't have to worry about modules.

Hi Matt, thank you very much again for this. I replaced all let with var and now getting an error on this line:
pointer.tap = () => console.log("The pointer was tapped");
SyntaxError: Unexpected token ')'

What is this = () => syntax? It is happening throughout the dust example code like during the d.create portion. Is there some equivalent for Safari? I realize this is possibly more about Safari than dust, but I don't know what to google for. Any thoughts would be greatly appreciated. Thank you again!

The () -> (arrow) and ()=> (fat arrow) are syntactic sugar that is part of the ES2015 javascript spec. They are a shorthand for functions: ()-> replaces function(){} and the fat arrow syntax does the same thing except it indicates a bound function. Your confusion is caused by the fact that ES2015 is not fully implemented in all browsers yet. You're also using an old version of Safari, which definitely doesn't implement most of it. Babel is a 'transpiler' that eats ES2015 (or other languages) and spits out 'legacy' javascript that will run in older browsers, depending on how you configure it. We are in a transitional time period now, with more people using Babel and other transpilers to get ES2015 features into their codebase before browsers implement them, so you'll see ES2015 in examples more and more frequently. I would recommend you read up on how the ES2015 spec adds to the javascript language. Here is a good starting point. If you are ready to start writing ES2015 you can use Babel, or one of the other transpilers (my fave is coffeescript ) that give you access to ES2015 features across browsers. Good luck!

Oh wow, incredible! I can not thank you enough, sir! May you live long and prosper. Thanks again.