WICG / scroll-to-text-fragment

Proposal to allow specifying a text snippet in a URL fragment
Other
586 stars 43 forks source link

Behavior or ZeroWidthSpace #253

Open ktangri opened 7 months ago

ktangri commented 7 months ago

The documentation for scrolling to text fragment mentions that whitespace is ignored and I see explicit mention of how &nbsp characters are handled. However, I do not see any mention of how &ZeroWidthSpace is handled nor can I seem to link a text fragment that has &ZeroWidthSpace as a prefix.

Below is what I am trying to match with (what I think) is the relevant information extracted. I want to match the 2,806 (appears multiple times with the same suffix so requires a prefix).

<table>
    <tbody>
        <tr>
            <td>...</td>
            ...
            <td><ix:nonfraction>66.05</ix:nonfraction></td>
            <td><em>&nbsp</em></td>
        </tr>
        <tr>
            <td><p>&ZeroWidthSpace</p></td>
            <td><em>&nbsp</em></td>
            <td><em>&nbsp</em></td>
            <td><ix:nonfraction>2,806</ix:nonfraction></td>
            ...
        </tr>
    </tbody>
</table>

What I've Tried:

Is there something I am missing here? What is the expected behavior of ZeroWidthSpace?

bokand commented 7 months ago

Thanks for filing. I don't think we've explicitly covered it and this results on some edge-cases...

From what I can tell a zwsp is collapsed along with other whitespace in matching so text=foo will match "f​oo" but it isn't treated as whitespace when looking for context so text=f-,oo will fail.

The intent is that it should be treated as whitespace in both contexts so this is a bug.

(Note: see also #250 - I'll try to address these together)

ktangri commented 7 months ago

Appreciate the confirmation! Just to clarify - after you make any necessary changes, browsers will still need to update their versions of this in order for it to be supported right?

bokand commented 7 months ago

Yes, that's right. I haven't tried to see what Safari does yet, does it behave similarly?

ktangri commented 7 months ago

Just confirmed that Safari (similar to Chrome) does not ignore the zwsp when trying to match text=66.05-,2%2C806