tornadofx: CSS Splitting Bug

I’m not sure why I didn’t notice this before, but there is a bug in the way CSS comma separated selectors are split. For example:

s("A, B") {
    s("C, D") {
        textFill = c("green")
    }
}

should produce:

A C, B C, A D, B D {
    -fx-text-fill: rgba(0, 128, 0, 1);
}

but instead produces:

AC, B C, AD, B D {
    -fx-text-fill: rgba(0, 128, 0, 1);
}

(notice the lack of space after A both times).

This has to do with the fact that the , immediately follows A when stored. A naive solution would be to just add a space after splitting the string, but that would break in the following case:

s("A, B") {
    +s("C, D") {
        textFill = c("green")
    }
}

where you would get:

A C, BC, A D, BD {
    -fx-text-fill: rgba(0, 128, 0, 1);
}

This could be fixed by doing checks on whether the value of current ends in a space, but I’m not sure how many more weird bugs are going to pop up in these kinds of corner cases, each of which requiring its own hack to get around.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 95 (42 by maintainers)

Most upvoted comments

Awesome. Thanks for all your work t-boom. This feature even in prototype has been enormously helpful at work for me.

What!!! Okay, I’ll live with that if it is cleaner…

Haha you know why the world belongs to procrastinators? Because things change at the last minute. I’ll update the documentation if we all agree this is better.

The s() did feel weird to me at first, and then I got used to it, and then attached to it. Weird how developers are trained to be counterintuitive.

We should probably just kill the s once and for all.