[Webkit-unassigned] [Bug 83993] Unsupported commands in execCommand/queryCommand* should throw except queryCommandSupported

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Fri Apr 20 00:38:27 PDT 2012


https://bugs.webkit.org/show_bug.cgi?id=83993





--- Comment #24 from Aryeh Gregor <ayg at aryeh.name>  2012-04-20 00:38:26 PST ---
(In reply to comment #23)
> What I see as a subtle, but conceptual difference is that exceptions in these cases are always indication of a programming mistake, not a side channel to inform developer of browser limitations.

What about querySelector() with a selector that's not supported yet?  Or what about a method or interface that's just not supported at all?  Calling, say, history.pushState() (or any other method) will throw if the feature isn't supported.  Why should document.execCommand("defaultparagraphseparator") be different?  In fact, if I were designing this API from scratch, I'd make it look something like

  // document.execCommand("bold");
  document.editing.bold.exec();
  // document.queryCommandEnabled("bold");
  document.editing.bold.enabled;
  // document.queryCommandIndeterm("bold");
  document.editing.bold.indeterm;
  // document.queryCommandState("bold");
  document.editing.bold.state;
  // document.queryCommandSupported("bold");
  "bold" in document.editing;

and all of these but the last would throw if "bold" wasn't supported.

> The consequence of ignoring this command is that font size won't change, which may or may not be important to the user, and should be caught in testing if it's a feature important to the developer. Using a wrong font size is superior to being completely broken due to uncaught exception.

True, but the same could be said for almost anything -- authors who want to use new features will tend to get completely broken pages if they don't test in browsers they care about.  How many recently-introduced new features can actually be used without risk of completely breaking other browsers?  Looking at the last "Last week in WebKit":

http://www.webkit.org/blog/1983/last-week-in-webkit-css-khtml-and-apple-and-ancestororigins/

New features there include location.ancestorOrigins() and the Battery Status API.  Both will throw if you use them in browsers that don't support them.  CanvasRenderingContext2D.backingStorePixelRatio won't throw immediately in browsers that don't support it, but real-world use might well throw or otherwise break completely if it's treated as a number, because it will unexpectedly be zero (and authors might divide by it, etc.).

So I think throwing for unsupported new features is par for the course on the web platform, and execCommand() should be no different.

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list