Non-elements between adjacent and general sibling combinators should be skipped
wooorm opened this issue · comments
Titus commented
This does not work:
st.deepEqual(
select(
'h1 + p',
u('root', [
u('text', '\n'),
h('p', 'Alpha'),
u('text', '\n'),
h('h1', 'Bravo'),
u('text', '\n'),
h('p', 'Charlie'),
u('text', '\n'),
h('p', 'Delta'),
u('text', '\n'),
h('div', [h('p', 'Echo')])
])
),
h('p', 'Charlie'),
'should return adjacent sibling (whitespace)'
)
It does work if there is no inter-element whitespace.
Affects +
, but probably also ~
and >
Titus commented
To clarify, all non-element siblings are skipped:
<style>
#a a + b {
color: red;
}
#b a ~ b {
color: red;
}
</style>
<div id=a>
<a>Lorem</a> ipsum <b>dolor</b> sit <i>amet</i> sed <b>do</b> eiusmod <i>tempor</i>.
</div>
<div id=b>
<a>Lorem</a> ipsum <b>dolor</b> sit <i>amet</i> sed <b>do</b> eiusmod <i>tempor</i>.
</div>