2 ms·
It looks strange to me, language designed to work with trees so turn everything to tree. No need to change serialization, we know format, just parse it — class,
by sergeykish 6y ago
It looks strange to me, language designed to work with trees so turn everything to tree. No need to change serialization, we know format, just parse it — class, URL, CSS. That's what we do in JavaScript [1], [2], [3].
location.host === 'example.com'
span.style.color === 'blue'
datet.getFullYear() === 2020
//a[href/host = 'example.com']
//span[xstyle/color = 'blue']
//date[datetime/year = '2020']
Just like your proposal but node knows how to parse itself
//a[url-host(@href) = 'example.com']
//span[css-color(@style) = 'blue']
//time[datetime-year(@datetime) = '2020']
And it is actual syntax, I've checked on
<a><href><host>example.com</host></href></a>
<span><xstyle><color>blue</color></style></span>
<date><datetime><year>2020</year></datetime></date>
* <style> is CDATA, emulated with <xstyle>
[1] https://developer.mozilla.org/en-US/docs/Web/API/DOMTokenList https://developer.mozilla.org/en-US/docs/Web/API/DOMTokenLis...
[2] https://developer.mozilla.org/en-US/docs/Web/API/URL https://developer.mozilla.org/en-US/docs/Web/API/URL
[3] https://developer.mozilla.org/en-US/docs/Web/API/CSS_Object_Model https://developer.mozilla.org/en-US/docs/Web/API/CSS_Object_...