Skip to content

ES2015 classes cannot be used with Mithril #735

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

Closed
dead-claudia opened this issue Jul 25, 2015 · 7 comments
Closed

ES2015 classes cannot be used with Mithril #735

dead-claudia opened this issue Jul 25, 2015 · 7 comments

Comments

@dead-claudia
Copy link
Member

Basically, this line will throw in any ES2015 class implemented with correct semantics. The problem is that you can only .bind classes; you can't .apply or call them with anything. In io.js 2.4.0, which does implement correct semantics (Babel can't due to ES5 restrictions):

> class F {}; F.apply(Object.create(F.prototype))
TypeError: Class constructors cannot be invoked without 'new'
    at new F (repl:1:23)
    at repl:1:37
    at REPLServer.defaultEval (repl.js:154:27)
    at bound (domain.js:254:14)
    at REPLServer.runBound [as eval] (domain.js:267:12)
    at REPLServer.<anonymous> (repl.js:308:12)
    at emitOne (events.js:77:13)
    at REPLServer.emit (events.js:169:7)
    at REPLServer.Interface._onLine (readline.js:210:10)
    at REPLServer.Interface._line (readline.js:549:8)
@dead-claudia
Copy link
Member Author

Same thing with Chrome in strict mode + #enable-javascript-harmony:

> (function() { 'use strict'; class F {}; return F.apply(Object.create(F.prototype)) })()
Uncaught TypeError: Class constructors cannot be invoked without 'new'
    at new F (<anonymous>:2:29)
    at <anonymous>:2:50
    at <anonymous>:2:86
    at Object.InjectedScript._evaluateOn (<anonymous>:905:140)
    at Object.InjectedScript._evaluateAndWrap (<anonymous>:838:34)
    at Object.InjectedScript.evaluate (<anonymous>:694:21)

@Naddiseo
Copy link
Contributor

Duplicate of #618 ?

@dead-claudia
Copy link
Member Author

No. Consider this blocking that bug. This is limited to merely ES6 classes
for "component".

On Mon, Jul 27, 2015, 14:04 Richard Eames [email protected] wrote:

Duplicate of #618 #618 ?


Reply to this email directly or view it on GitHub
#735 (comment).

@dead-claudia
Copy link
Member Author

Clarification: the "component" property.

On Mon, Jul 27, 2015, 17:16 Isiah Meadows [email protected] wrote:

No. Consider this blocking that bug. This is limited to merely ES6 classes
for "component".

On Mon, Jul 27, 2015, 14:04 Richard Eames [email protected]
wrote:

Duplicate of #618 #618 ?


Reply to this email directly or view it on GitHub
#735 (comment).

@dead-claudia
Copy link
Member Author

s/component/controller/g...
What I mean is this is supposed to work:

var component = {
  controller: class { /* ... */ },
  view(ctrl) { /* ... */ },
}

On Mon, Jul 27, 2015, 17:31 Isiah Meadows [email protected] wrote:

Clarification: the "component" property.

On Mon, Jul 27, 2015, 17:16 Isiah Meadows [email protected] wrote:

No. Consider this blocking that bug. This is limited to merely ES6
classes for "component".

On Mon, Jul 27, 2015, 14:04 Richard Eames [email protected]
wrote:

Duplicate of #618 #618 ?


Reply to this email directly or view it on GitHub
#735 (comment)
.

@Naddiseo
Copy link
Contributor

var component = {
  controller: class { /* ... */ },
  view(ctrl) { /* ... */ },
}

That does work.. at least in chrome 43: https://jsfiddle.net/wv5jfoyh/

And if you mean not working with m.component, that's exactly what #618 is about.

@lhorie
Copy link
Member

lhorie commented Dec 21, 2015

reading again, this does look like a dupe of #618 to me, so I'm closing this

@lhorie lhorie closed this as completed Dec 21, 2015
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