Jump to content

Issues building UIKit from src with LESS - Operation on invalid type


Recommended Posts

This is more just a reminder post than a problem post.

If you have been having issues building UIKit from more recent repos it may be because the math setting in the currently used LESS.php wikimedia version is a bit greedy.

Even after setting the 

'math' => 'strict'

option in the $less object it still gave an 'Operation in invalid type error'.

I forgot that I needed to modify two files in order to get this to compile. base.less and article.less have two variable calculations that need to be quote escaped. Basically you need to turn this:

@base-h1-font-size-m * 0.85;

into this:

~'calc(' @base-h1-font-size-m ~'* 0.85)';

No matter how many times I write this someplace I forget that it needs to happen. So I am saving it here for the next time I desperately search for it.

  • Like 2
Link to comment
Share on other sites

Thx for sharing! I'm not having any issues, so I'm wondering why? I'm using latest UIkit and latest LESS module. Do I have to adjust something specific? Would it be worth to create an issue for the uikit team so that they can account for that use case?

Link to comment
Share on other sites

It may depend on how you define your LESS variables, and whether you use CSS variables or not.

This is something that the Wikimedia LESS and other frameworks run into from time to time - it's not unique to UIkit. Usually the strict math option resolves it because parenthesis are required to indicate math operators that LESS should evaluate - so I was surprised this was still choking, and it wasn't stopping on my custom mod LESS (partly because I had already quote escaped the math I needed to protect from LESS) - it was choking on stock UIKit source. The issue started for me with UIKit 3.18

I looked into whether the math setting changes may have an impact because of what others found on unrelated frameworks.

In my particular case, I allow for dynamic type scaling in theme options based on variables, and I use dynamic font scaling to maintain line line lengths also. In my case when you allow LESS to do the math on its own it sometimes the parser is too greedy.

I do wonder if using the up-to-date LESS.php package (I think it is 4.4.1 when I dug into it yesterday) would help, but I found it wasn't necessarily a direct drop-in for some reason. I ended up reverting to the default module.

  • Like 1
Link to comment
Share on other sites


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...