javascript - range getClientRects(), getBoundingClientRect() wrong when empty anchor is in HTML paragraph -
i found possibly weird behaviour of getclientrects() [getboundingclientrect()]
:
look @ html code:
<p>text here... word1<a id='id' class='class'/>word2 other multiline text here...</p>
[note element has no text inside, tested kind of code, don't know if other arrangements give same 'bug'.]
let's when user selects range in p 'estate' has anchor inside, "word1 word2", js function stores start/end elements , offsets. next time function creates range bounds. if getclientrects()
called on range yields many rects other 2 expected: first , last rects of array indeed expected ones, but, between them, there many rects in fact cover entire p element. [range.getboundingclientrect()
affected too.] how avoid this?
Comments
Post a Comment