cfuendev / twimba

CSS-in-JS for Imba's CSS syntax.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Writing standard CSS property names breaks the code parsing process

cfuendev opened this issue · comments

While testing the ideas mentioned in #2, I also found out that cursor:pointer is being transpiled as cursor: pointer: because the cursor and pointer css properties are overlapping.

image

So turns out the real problem is that the code snippet that shoved standard property names property names that aren't registered as Imba shorthand to the final code formatting step (The step that puts property names behind colons : and property values in-between colons : and semicolons ;) wasn't in the right place and, instead of being the final case after the property name wasn't found in the list of shorthands, it was placed inside the if statement that verifies that there's a shorthand for the parsed property name, completely undermining the reason why that snippet exists in the first place.

In case you want to take a look, this is the if statement. It's line 495 on the twimba.js file of the current commit (b9f6e9b)

if (propertyNameRule) {

That if statement makes sure that there is a shorthand rule for the text that's currently in the buffer during the parsing process and, if there is none, it should then look for it on the custom property value rules (Basically anything that transpiles into more than one property, think of d:vflex, display:hgrid, px, margin-y, etc. with the exception of easing properties, which are handled differently and were an absolute pain in the back-end to get working).

So instead of putting the code snippet that should be a fallback to shoving whatever has been parsed as the property name if there is no known shorthand for it (Which would be the case if you're simply writing background or, the property that created this issue, cursor) outside of the if statement (Which is the entire point of the snippet, being outside of that if statement), I left it inside the if statement by accident, probably during one of the fever dreams that building the macro for the first time put me through.

I will change the name of the issue to reflect the actual nature of the bug.