GithubHelp home page GithubHelp logo

parser: support data-dojo-mixin? about delite HOT 9 CLOSED

ibm-js avatar ibm-js commented on July 28, 2024
parser: support data-dojo-mixin?

from delite.

Comments (9)

ccmitchellusa avatar ccmitchellusa commented on July 28, 2024

Could we define a d-mixin custom element to do the behavior mixin, rather than custom parsing of data attribute, eg.

<d-treemap data-mixins="">
   <d-mixin>dtreemap/Keyboard</d-mixin>
</d-treemap>

from delite.

wkeese avatar wkeese commented on July 28, 2024

I'm not sure why we would do that. It seems more complicated.

from delite.

cjolif avatar cjolif commented on July 28, 2024

The alternative is to ask users to redefine their own tag:

register("my-treemap", [TreeMap, Keyboard]);

and then use it:

<my-treemap></my-treemap>

I think this is very linked to #27. If we don't get auto-loading, then honesty this is probably not dramatic to ask people to do this as they will anyway have to manually import the TreeMap module. But if we keep the idea of being able to simply write markup and not have to deal with JavaScript to import/instantiate modules then having to fallback to JavaScript for the mixins won't fit the strategy.

In other words, if we don't implement #27 and close it I think this makes sense to be "consistent" and close also this one. If we implement #27 then I think we should do something for that one as well so that the pure markup solution is complete.

from delite.

cjolif avatar cjolif commented on July 28, 2024
register("my-treemap", [TreeMap, Keyboard]);

won't work, apparently it needs to be:

register("my-treemap", [HTMLElement, TreeMap, Keyboard]);

despite TreeMap is already and HTMLElement.

Maybe we should have a helper function?

TreeMap.createSubWidget("my-treemap", [Keyboard]);

It should both include HTMLElement automatically and do the registration?

like we had in Dojo 1.X? Under that conditions it might be easier to accept the lack of data-dojo-mixins?

from delite.

wkeese avatar wkeese commented on July 28, 2024
register("my-treemap", [TreeMap, Keyboard]);

is supposed to work. I guess there's a bug; I'll look into it.

from delite.

cjolif avatar cjolif commented on July 28, 2024

Maybe there is something specific to the TreeMap that breaks this. Basically the widget is created but at runtime things like properties expected to be here are not and things like that.

from delite.

wkeese avatar wkeese commented on July 28, 2024

For the record, I talked privately to @cjolif and he couldn't reproduce the problem with

register("my-treemap", [TreeMap, Keyboard]);

I did add some unit tests (in register.js) to make sure that sort of thing works.

from delite.

wkeese avatar wkeese commented on July 28, 2024

For browsers that have native custom element support, you associate a prototype with a custom tag. I don't think it's practical or prudent to switch-out that prototype with a custom class we define on the fly.

So, if we did support data-mixin, the "classes" that we mix in would need to be lightweight objects. Perhaps a mixin would just be a function that would setting up advice on the main classes pre-existing methods.

from delite.

wkeese avatar wkeese commented on July 28, 2024

if we did support data-mixin, the "classes" that we mix in would need to be lightweight objects. Perhaps a mixin would just be a function that would setting up advice on the main classes pre-existing methods.

Realistically I don't see us doing that (although it would be an interesting experiment). Thus I'm closing this ticket and also #27 for now.

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.