Closed Phanx closed 11 years ago
You should always see how Scite handle these.
SciTE appears to handle these correctly. Pseudo-classes and pseudo-elements get (very slightly) different colors, while invalid pseudo-classes and invalid pseudo-elements are both clearly highlighted as "unknown".
According to MDN, :after
and :before
is CSS2 syntax and has better compatibility. Calling ::after
more "correct" than :after
is ... interesting. They are just different specs. CSS2 is still valid and correct.
https://developer.mozilla.org/en-US/docs/Web/CSS/Pseudo-elements
Nevertheless, I am currently working on a fix for this since you're correct that it should support the CSS3 syntax for pseudo-elements. I should be done with the patch within an hour (I'm just doing some research first). I'll just add it to my current Pull Request.
I'm not aware of any industry where older standards are considered "more correct" than newer standards, so yes, I'd call CSS3 syntax "more correct" than CSS2 syntax. Also, since the only browser with statistically significant market share that doesn't support the CSS3 syntax is Internet Explorer 8 -- which is currently at about 8 or 9% and on a steady decline -- I'd call any compatibility issues negligible.
Version: Notepad2-mod (64-bit) 4.2.25 r858 (3f0683d) Operating system: Windows 7 Professional (64-bit)
Steps to reproduce:
Expected result:
The keyword
before
in each of the example lines should be highlighted using the "Pseudo-class/element" settings.Observed result:
The
before
preceded by a single colon (first line) is highlighted as "Pseudo-class/element". However, thebefore
preceded by a double colon (second line) is highlighted as "Unknown Pseudo-class".Detailed explanation:
In earlier versions of CSS, a single colon was used for both pseudo-classes (eg.
img:first-child
matches anyimg
element that is the first child of its parent element) and pseudo-elements (eg.img::before
creates a "virtual element" that appears directly before eachimg
element in the document).Nowadays, the correct notation is to use a single colon for pseudo-classes, and a double colon for pseudo-elements. Though all current user-agents still recognize pseudo-elements with single colons (for compatibility reasons) it is very helpful as a developer to use the more distinct notation so when I'm looking at my code (or someone else's code) I can immediately tell what's what.
Ideally, Notepad2-mod should have separate highlighting settings for pseudo-classes and pseudo-elements, but that's probably a lot more work, and it's not that important, so it should just highlight them both the same.