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

Add support for native ES6 class Symbol #880

Closed
lgersman opened this issue Nov 4, 2014 · 13 comments
Closed

Add support for native ES6 class Symbol #880

lgersman opened this issue Nov 4, 2014 · 13 comments
Assignees

Comments

@lgersman
Copy link

lgersman commented Nov 4, 2014

I play a lot with ES6 and recognized that current Polymer (version 0.4.2) does'nt handle native Symbol usage properly.
ES6 class Symbol arrived natively in Chrome 38. Current Chrome is 39.

When you run the following example in Chrome(>=38) you'll get an error

Uncaught TypeError: Cannot convert a Symbol value to a string

Example code :

<!doctype html>
<html>
<head>
  <script src="http://www.polymer-project.org/components/platform/platform.js"></script>
  <link rel="import" href="http://www.polymer-project.org/components/polymer/polymer.html">
</head>
<body>
  <polymer-element name="es6-symboltest">
    <template>
      <pre>options[Symbol(foo)] = {{options[property]}}</pre>
    </template>
    <script>
      var symbol = Symbol('foo');

      Polymer({
        attached : function() {
          this.options[symbol] = "bar";
        },
        property : symbol,
        options : {

        }
      });
    </script>
  </polymer-element>

  <es6-symboltest></es6-symboltest>
</body>
</html>

I guess the polymer-expression-to-function-conversion compiler provocates this error.

Live example (press F12 to see error in webinspector!) : http://jsbin.com/wegero/1/edit?html,output

@ebidel
Copy link
Contributor

ebidel commented Nov 6, 2014

@jmesserly is this something you could look in to?

@jmesserly
Copy link
Contributor

Sure thing. Sounds neat.

@jmesserly jmesserly self-assigned this Nov 6, 2014
@jmesserly
Copy link
Contributor

hmmm. My first thought was a PolymerExpressions issue but it seems to work:
http://jsbin.com/ginonacata/1/edit?html,output

@jmesserly
Copy link
Contributor

aha. The example works if you use created event: http://jsbin.com/fokawetabe/1/edit

so it's not an issue of Symbols not working in the index expr, what seems to be happening is that modifying the object doesn't trigger a change event.

@jmesserly
Copy link
Contributor

... and/or the change event isn't handled correctly.

@jmesserly
Copy link
Contributor

Try this in the console:

var o = {}; Object.observe(o, function(r) { console.log(r); }); o['abc'] = 123; o[5] = 6; o[Symbol('foo')] = 'bar';

there's no change event for the symbol, even though the contents of o are Object {5: 6, abc: 123, Symbol(foo): "bar"}

@jmesserly
Copy link
Contributor

@lgersman
Copy link
Author

lgersman commented Nov 6, 2014

if i try your examplecreated example (http://jsbin.com/fokawetabe/1/edit) in chrome 39 I get the
Cannot convert a Symbol value to a string error too.

no difference. there might be 2 problems.

could you please reopen the bug because it fails also when using the created callback ?

@jmesserly
Copy link
Contributor

hmm, really? I'm also running Chrome Version 39.0.2171.52 beta (64-bit)
that link displays for me options[Symbol(foo)] = bar

I don't think I have any experimental flags turned on...

@jmesserly
Copy link
Contributor

More info that might help:

@lgersman
Copy link
Author

lgersman commented Nov 6, 2014

  • i have Chrome (currently @home) 38.0.2125.111 (64-bit).
  • this example works !

@jmesserly
Copy link
Contributor

Nice!

I wonder if maybe it's fixed in the latest Chrome beta then. Since Symbol is very new, I imagine there are changes from release to release as they find & fix bugs.

I just tried Version 40.0.2211.0 canary (64-bit), and this link works there too http://jsbin.com/fokawetabe/1/edit?html,output

@lgersman
Copy link
Author

lgersman commented Nov 6, 2014

Okay - thats good news !

So its the best to keep this issue closed for now.

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

3 participants