[whatwg] Selection API compatibility on exceptions

Hajime Morita morrita at google.com
Thu Apr 1 22:09:23 PDT 2010


Hi,
I'm working on WebKit and I found that there are an inconsistency
between spec and implementations around Selection API.

Some Selection APIs including collapse(), selectAllChildren() take DOM
nodes as arguments. And the spec says Selection should throw
WRONG_DOCUMENT_ERROR
if "if the given node is in a different document."
But neither Firefox, Opera, and Webkit throws such exception.
They accept foreign nodes (Firefox), or just gnore them (WebKit).
(I couldn't figure out how Opera behaves. It allows API to be called,
but nothing seems happen even with valid nodes.)
You can walk Selection behaviour with http://www.dodgson.org/t/selections.html

Although it is ideal to throwing exceptions, it may break existing
applications which depend current generous behaviour.
So it looks reasonable for me to change the spec to say not to throw
exceptions for foreign nodes, and just ignore them instead.

Any ideas?
-- 
morita



More information about the whatwg mailing list