GithubHelp home page GithubHelp logo

Upgrade to DCL V2 about delite HOT 7 CLOSED

wkeese avatar wkeese commented on July 28, 2024
Upgrade to DCL V2

from delite.

Comments (7)

uhop avatar uhop commented on July 28, 2024

Both issues in dcl v2 are fixed, and a new version 2.0.6 is published in npm.

BTW, there is another version of dcldcl6. It is a version for ES6 (classes, symbols, and so on). It is not published because there is no documentation, and tests for the debug module are unfinished. Yet, I use it already, and it should be understandable for users of dcl and, of course, there are tests.

BTW, some features of dcl6 were actually back-ported to dcl at some point or another.

from delite.

wkeese avatar wkeese commented on July 28, 2024

Thanks @uhop! I do know about dcl6 but I don't think we can use it because presumably it doesn't support IE11 (and we need to support IE11). Did I misinterpret?

It would be nice to use because the custom elements V1 API only works with classes. (That's according to https://github.com/webcomponents/custom-elements#es5-vs-es2015)

from delite.

uhop avatar uhop commented on July 28, 2024

You are correct, but partially. The way to do it nowadays is to use the modern JavaScript supported by all modern browsers, and transpire it for the rest, e.g., IE11, with Babel. Last time I checked dcl6 works when transpiled and used with a standard Web Component shim.

from delite.

wkeese avatar wkeese commented on July 28, 2024

Ah that makes sense. Actually we are already transpiling, so I guess we could switch to dcl6, but I'll put it down for a "stage 2" because it's a big syntax change.

It might be nice though if dcl2 created ES6 classes behind the scenes, when ES6 was supported. Or are you already doing that?

from delite.

uhop avatar uhop commented on July 28, 2024

It does use ES6 classes inside. Something like that:

const NewClass = dcl(BaseClass, Mixin1, Mixin2, Base => class extends Base {
  constructor() {
    super();
    // ... do stuff
  }

  method1() { /* ... */ }

  get prop1() { return this._prop1; }
  set prop1(value) { this._prop1 = value; }
});

The usual ES6 class stuff. Plus chains and AOP.

The reason I didn't publish it yet: there is an effort to bring decorators to ES6 classes. The discussion never ends. But I don't want to commit to something totally incompatible with the result. OTOH, for now, I decided to use a separate directive object, which lends itself to future decorators whatever they are. Of course, it is all predicated on them being not completely brain-dead.

Another reason is I didn't decide on packaging yet. Most probably I'll leave it to application developers and provide raw ES6 code.

Look at tests to get the feel. They are mostly ported from dcl v2.

from delite.

wkeese avatar wkeese commented on July 28, 2024

I was actually suggesting the dcl version 2 internally use classes (on supported browsers), so that it could also be used with CustomElementRegistry.define(). Not sure if it's a good idea or not.

from delite.

uhop avatar uhop commented on July 28, 2024

Not doable. Unfortunately class is not a syntax sugar as popularly believed. It is the only way to subclass native objects like Array or HTMLElement. It is not possible to do by messing with prototypes in JavaScript. So I had to redo how mixins are defined and how chains/AOP declared. Essentially dcl6 is dcl v2 with classes and an updated API to facilitate the change.

You can think that dojo.declare() was for ES3, dcl was for the incomplete ES5, dcl v2 is for the complete ES5 (+ properties), dcl6 is for ES6 (+ classes, symbols, more introspection).

from delite.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.