Coder Social home page Coder Social logo

Comments (9)

kbrsh avatar kbrsh commented on August 21, 2024

It's actually expected behavior at the moment, adding a boolean value to something will make the actual value of it that boolean. It doesn't conditionally render.

The only item that is treated special is classes, for example:

<!-- array of classes in m-literal applies all of them during a build -->
<h1 m-literal:class="['bar', 'baz']">Foo</h1>

<!-- object of classes conditionally adds them -->
<h1 m-literal:class="{bar: true, baz: false}">Foo</h1>

I guess I can add behavior to the prop diff to conditionally add elements if they are a boolean. It'll be coming in v0.9.0.

from moon.

bovisp avatar bovisp commented on August 21, 2024

@kingpixil Many thanks for your prompt replies over the last day. I'm a user of VueJS, but the speed and size of your framework is really intriguing to me.

Might this conditional HTML attribute rendering also extend to things such as "checked" and "selected"?

from moon.

kbrsh avatar kbrsh commented on August 21, 2024

@bovisp No problem! I can't thank you enough for the great feedback you give, it really helps. After I fix a couple more bugs, v0.9.0 will be out! 🎉

Yup! The conditional HTML attributes work for anything provided as a boolean, including component properties as well!

from moon.

bovisp avatar bovisp commented on August 21, 2024

@kingpixil I'm happy to help. I'm in the process of creating some Moon examples using a codepen project. I'm basically retaking Laracasts' Vue 2.0 Step-by-Step and then Moon-ifying the resulting code. It will take me a while.

The project is in very rough shape right now and I only have four "hello world" type examples so far. They will be building in complexity as I move through the tutorials. I'll be renaming the HTML files and creating a landing page soon. The link is: https://codepen.io/tcdd/project/editor/ZoyVqA/

from moon.

bovisp avatar bovisp commented on August 21, 2024

And I was able to get conditional classes working via m-literal:class with no issues using your API docs.

from moon.

kbrsh avatar kbrsh commented on August 21, 2024

That's super cool! Love the examples 👍

from moon.

brogier avatar brogier commented on August 21, 2024

Has this been fixed? Still having this issue with 0.10.0

from moon.

brogier avatar brogier commented on August 21, 2024
for (var nodePropName in nodeProps) {
        var _vnodePropValue = vnodeProps[nodePropName];
        if (_vnodePropValue === undefined || _vnodePropValue === false || _vnodePropValue === null) {
          node.removeAttribute(nodePropName);
        }
      }

node.removeAttribute(nodePropName); is trying to remove property m-literal:disabled instead of disabled. Any idea how this is possible?

from moon.

kbrsh avatar kbrsh commented on August 21, 2024

Ahh, thank you for bringing this to my attention. The condition was removed in some previous commit, it should be fixed in v0.11.0.

from moon.

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.