[whatwg/dom] Define criteria for StaticRange validation (#947)

Because static ranges are not kept up-to-date during DOM mutations, UAs/authors need to validate the static ranges before actually using them. The criteria for checking if a StaticRange is valid seems to be:
- The start and end containers of the static range should be in the same (non-flat) DOM tree.
- The start offset is between 0 and the start container’s node length (inclusive).
- The end offset is between 0 and the end container’s node length (inclusive).
- The position of the start boundary point should be before or equal to the position of the end boundary point.

My questions are:
(1) Should we include these criteria as part of the StaticRange spec so that all UAs and authors can follow the same?
(2) If the answer to (1) is yes, I wonder if it is also worth having a public DOM API that does this, something like: `StaticRange.IsValid`?

Note that I'm only talking about specifying _what_ the validity criteria should be, not _when_ these validity checks should be run. The _when_, in my opinion, should be left up to the individual use case. (Ideally, validity is checked on-demand, only when necessary.)

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/947

Received on Thursday, 11 February 2021 08:34:47 UTC