Sdk: Range.fromPoint is not supported in all browsers

Created on 8 Jul 2013  路  9Comments  路  Source: dart-lang/sdk

_This issue was originally filed by da...@altern.org_


What steps will reproduce the problem?

  1. Try to use Range.fromPoint with Firefox
  2. Get an error
  3. For completion, try it with IE, Safari and Opera.

What is the expected output? What do you see instead?
I expect to get a new Range object. Instead I get the error
"TypeError: document.caretRangeFromPoint is not a function"

What version of the product are you using? On what operating system?
Dart SDK 0.5.20.4_r2475 , Firefox 22, Ubuntu 12.04

Please provide any additional information below.
This bug is related to Issue #9227.
With recent versions of Firefox, caretPositionFromPoint could be used instead of caretRangeFromPoint. With older versions, MouseEvent.rangeParent and MouseEvent.rangeOffset could be used with an event. With IE it can be done with textRange.moveToPoint. Implementing this method on all Dart supported browsers is not easy, but it would be good to at least improve support to more browsers and provide a way to check if the feature is supported by the browser.

See https://developer.mozilla.org/en-US/docs/Web/API/document.caretPositionFromPoint
and http://stackoverflow.com/a/3208216/438970

area-library area-web library-html type-bug

All 9 comments

_This comment was originally written by da...@altern.org_


Note that caretRangeFromPoint is mentionned in an old draft of CSSOM:
http://www.w3.org/TR/2009/WD-cssom-view-20090804/#dom-documentview-caretrangefrompoint

But it has been replaced by caretPositionFromPoint in the latest version:
http://dev.w3.org/csswg/cssom-view/#dom-document-caretpositionfrompoint

_Added Area-HTML, Triaged labels._

_Added this to the Later milestone._

_Removed Area-HTML label._
_Added Area-Library, Library-Html labels._

_Removed this from the Later milestone._
_Added Oldschool-Milestone-Later label._

_Removed Oldschool-Milestone-Later label._

Any update to this issue? It is very confusing since the API is not marked as experimental or not working on firefox. What's the general policy in this case? Chrome is not updating its API to the latest draft but firefox has implemented the latest. Is Dart HTML API supposed to mirror Chrome's status or the latest draft?

@alan-knight any news on this?

De facto, dart:html's API is generated from Chrome's IDL. Unfortunately the Chrome IDL is non-standard here, and the IDL file has a comment at the beginning of that section saying "non-standard APIs", but they aren't actually flagged in the IDL as experimental or unstable. And those annotations aren't even visible to users anyway. So in the short term added a comment in https://codereview.chromium.org/1578103003

Longer term it would be good to have a portable solution, but that's non-trivial.

Was this page helpful?
0 / 5 - 0 ratings