Code Monkey home page Code Monkey logo

staticrange's People

Contributors

garykac avatar

Watchers

 avatar  avatar  avatar

staticrange's Issues

Define toRange() more precisely

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:

  1. Let range be a new range
  2. Set the start of range to ...
  3. Set the end of range to ...
    https://dom.spec.whatwg.org/#concept-range-bp-set
  4. Return range

@annevk @domenic, do we like "Rethrow any exceptions" these days?

Give StaticRange a constructor

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.

Step 5 of "is valid" doesn't make sense

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...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.