li works but div is not #22

Open
opened 2025-10-14 18:01:12 -06:00 by navan · 0 comments
Owner

Originally created by @x4080 on 2/10/2022

html file :

<div class="items">
    <div class="someclass">
        <h2>first item</h2>

        <div data-video="av1">a</div>
        <div data-video="bv1">b</div>
        <div data-video="cv1">c</div>

        <li data-video="av1">a</li>
        <li data-video="bv1">b</li>
        <li data-video="cv1">c</li>

    </div>
</div>

if we find li with data=video, it works fine

x(html, '.items>.someclass',{
    tags: ['li@data-video']
}).then(function (res) {
    console.log(res) // output is json 
})
    .catch(function (err) {
        console.log(err) // handle error in promise
    })

result is { tags: [ 'av1', 'bv1', 'cv1' ] }

but if we try to find div with data=video result is null

x(html, '.items>.someclass',{
    tags: ['div@data-video']
}).then(function (res) {
    console.log(res) // output is json 
})
    .catch(function (err) {
        console.log(err) // handle error in promise
    })

result is { tags: [ null ] }

Why is it different between li and div ? I try to rename div to divx, and it works, just div that wont work

*Originally created by @x4080 on 2/10/2022* html file : ``` <div class="items"> <div class="someclass"> <h2>first item</h2> <div data-video="av1">a</div> <div data-video="bv1">b</div> <div data-video="cv1">c</div> <li data-video="av1">a</li> <li data-video="bv1">b</li> <li data-video="cv1">c</li> </div> </div> ``` if we find li with data=video, it works fine ``` x(html, '.items>.someclass',{ tags: ['li@data-video'] }).then(function (res) { console.log(res) // output is json }) .catch(function (err) { console.log(err) // handle error in promise }) ``` result is { tags: [ 'av1', 'bv1', 'cv1' ] } but if we try to find div with data=video result is null ``` x(html, '.items>.someclass',{ tags: ['div@data-video'] }).then(function (res) { console.log(res) // output is json }) .catch(function (err) { console.log(err) // handle error in promise }) ``` result is { tags: [ null ] } Why is it different between li and div ? I try to rename div to divx, and it works, just div that wont work
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github/x-ray#22
No description provided.