garykac / staticrange Goto Github PK
View Code? Open in Web Editor NEWStaticRange
StaticRange
This language is used in the "is less than" operation. What you probably want to use instead is https://dom.spec.whatwg.org/#concept-tree-preceding complete with link.
According to the StaticRange.idl I found (not sure if that's the latest one) there are some duplicate methods with Range.
See @dtapuska comments below, do we still want to make it interface Range : StaticRange
?
BTW would it be better to have the an idl inside this explainer?
Here is the idl #2 (comment)
Also According to the StaticRange.idl I found there is an empty Constructor.
But since StaticRange is immutable shouldn't the constructor be something like Constructor(optional StaticRangeInit)
or Constructor(Node, unsigned long, Node, unsigned long)
?
The step is:
If sr’s startOffset is less than 0 or sr’s endOffset is less than 0,
Offsets are unsigned, so they can't be less than 0.
https://garykac.github.io/staticrange/#dom-staticrange-torange
Returns a new Range with the same start and end as the context object.
This is a convenience method to up-convert a StaticRange into a full-featured Range object that can be used when the application requires the additional functionality provided by a Range.
It is equivalent to:
var newRange = document.createRange()
newRange.selStart(staticRange.startContainer, staticRange.startOffset);
newRange.selEnd(staticRange.endContainer, staticRange.endOffset);
It's not clear which parts of this are intended to be normative. At first glance, I would take only "Returns a new Range with the same start and end as the context object" to be a requirement on implementations, and the rest to be non-normative explanatory text.
It would be clearer as an algorithm:
@annevk @domenic, do we like "Rethrow any exceptions" these days?
It's now immutable, but could still have a constructor:
dictionary StaticRangeInit {
required Node startContainer;
required unsigned long startOffset;
required Node endContainer;
required unsigned long endOffset;
};
[Constructor(StaticRangeInit initDict)]
interface StaticRange { ... };
If there's no use for invalid ranges, then it could throw if http://garykac.github.io/staticrange/index.html#to-is-valid does not hold.
The draft says:
Any StaticRange that is generated by the user agent MUST be valid.
But what does that mean in practice? What are black-box circumstances where one could tell that this constraint is violated? I haven't been able to come up with any off the top of my head so far...
Things like:
If sr’s startOffset is greater than the size of the startContainer,
Presumably it means "the number of children of the startContainer". That's the terminology other specs use for this.
Step 5 says:
If sr’s collapsed is not equal to the result of calling is collapsed with sr,
But the return value of "collapsed" is defined to be the result of executing "is collapsed". So the two booleans are always the same, by definition...
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.