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

Strange reordering in specific cases when using conditionals #51

Closed
livtanong opened this issue Apr 14, 2014 · 3 comments
Closed

Strange reordering in specific cases when using conditionals #51

livtanong opened this issue Apr 14, 2014 · 3 comments
Labels
Type: Bug For bugs and any other unexpected breakage

Comments

@livtanong
Copy link
Contributor

Since the cdns aren't working, I'll just go directly into code here, rather than using jsfiddle.

works:

app = {
  controller: function(){
    this.someList = m.prop([1, 2, 3, 4, 5, 6]);
    this.isVisible = m.prop(true);
    this.toggleVisible = function(){
      this.isVisible(!this.isVisible());
    }
  },
  view: function(ctrl){
    return m("div", [
      m("button", 
        {onclick: ctrl.toggleVisible.bind(ctrl)}, 
        "toggle!"),
      m("div", [
        ctrl.isVisible() ? m("div", "on") : m("div", "off"),
        m("div", "all the other shit")
      ])
    ]);
  }
}
m.module(document, app);

Funky cases:

...
ctrl.isVisible() ? m("div", "on") : "",
...
ctrl.isVisible() ? m("div", "on") : m("span", "off"),
...
ctrl.isVisible() ? m("div", "on") : m("button", {onclick: /*something*/},"off"),

When they're generated, they're appended to the bottom of the list, like the previous bugs.

As far as I've tested, conditional ordering really only works properly on divs.

@lhorie
Copy link
Member

lhorie commented Apr 14, 2014

Thanks for the bug report! I'm trying to nail down all the edge cases where this issue is happening, so this is really useful.

@lhorie lhorie added the bug label Apr 14, 2014
@lhorie
Copy link
Member

lhorie commented Apr 14, 2014

The following case also breaks:

ctrl.isVisible() ? m("div", "on") : m.trust("foo")

@lhorie
Copy link
Member

lhorie commented Apr 14, 2014

All the cases are fixed in v0.1.8, which is now released. CDNs are not up to date yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug For bugs and any other unexpected breakage
Projects
None yet
Development

No branches or pull requests

2 participants