This is revision 1.5612.
The definition of the terms active range, editing
host, and editable, the user interface requirements
of elements that are editing hosts
or editable, the
execCommand()
,
queryCommandEnabled()
,
queryCommandIndeterm()
,
queryCommandState()
,
queryCommandSupported()
, and
queryCommandValue()
methods, and text selections are defined in the HTML Editing APIs
specification. The interaction of editing and the undo/redo features
in user agents is defined by the UndoManager and DOM Transaction
specification. [EDITING] [UNDO]
User agents can support the checking of spelling and grammar of
editable text, either in form controls (such as the value of
textarea
elements), or in elements in an editing
host (e.g. using contenteditable
).
For each element, user agents must establish a default behavior, either through defaults or through preferences expressed by the user. There are three possible default behaviors for each element:
The spellcheck
attribute is an enumerated attribute whose keywords are
the empty string, true
and false
. The empty string and the true
keyword map to the true state. The false
keyword maps to the false state. In
addition, there is a third state, the default state, which is
the missing value default (and the invalid value
default).
The true state indicates that the element is
to have its spelling and grammar checked. The default state
indicates that the element is to act according to a default
behavior, possibly based on the parent element's own spellcheck
state, as defined below.
The false state indicates that the element is not to be
checked.
spellcheck
[ = value ]Returns true if the element is to have its spelling and grammar checked; otherwise, returns false.
Can be set, to override the default and set the spellcheck
content attribute.
The spellcheck
IDL
attribute, on getting, must return true if the element's spellcheck
content attribute is in
the true state, or if the element's spellcheck
content attribute is in
the default state and the element's default behavior is true-by-default, or
if the element's spellcheck
content attribute is in the default state and the element's
default behavior is
inherit-by-default
and the element's parent element's spellcheck
IDL attribute would return
true; otherwise, if none of those conditions applies, then the
attribute must instead return false.
The spellcheck
IDL attribute is not affected by user preferences that override the
spellcheck
content attribute,
and therefore might not reflect the actual spellchecking state.
On setting, if the new value is true, then the element's spellcheck
content attribute must be
set to the literal string "true
", otherwise it
must be set to the literal string "false
".
User agents must only consider the following pieces of text as checkable for the purposes of this feature:
input
elements to which the readonly
attribute applies,
whose type
attributes are not
in the Password
state, and that are not immutable (i.e. that do not
have the readonly
attribute specified and that are not disabled).textarea
elements that do not have a
readonly
attribute and
that are not disabled.Text
nodes that are
children of editing hosts or
editable elements.For text that is part of a Text
node, the element
with which the text is associated is the element that is the
immediate parent of the first character of the word, sentence, or
other piece of text. For text in attributes, it is the attribute's
element. For the values of input
and
textarea
elements, it is the element itself.
To determine if a word, sentence, or other piece of text in an applicable element (as defined above) is to have spelling- and/or grammar-checking enabled, the UA must use the following algorithm:
spellcheck
content
attribute, then: if that attribute is in the true state,
then checking is enabled; otherwise, if that attribute is in the
false state, then checking is disabled.spellcheck
content attribute that is
not in the default state, then: if the nearest such
ancestor's spellcheck
content
attribute is in the true state, then checking is enabled;
otherwise, checking is disabled.If the checking is enabled for a word/sentence/text, the user
agent should indicate spelling and/or grammar errors in that
text. User agents should take into account the other semantics given
in the document when suggesting spelling and grammar
corrections. User agents may use the language of the element to
determine what spelling and grammar rules to use, or may use the
user's preferred language settings. UAs should use
input
element attributes such as pattern
to ensure that the
resulting value is valid, where possible.
If checking is disabled, the user agent should not indicate spelling or grammar errors for that text.
The element with ID "a" in the following example would be the one used to determine if the word "Hello" is checked for spelling errors. In this example, it would not be.
<div contenteditable="true"> <span spellcheck="false" id="a">Hell</span><em>o!</em> </div>
The element with ID "b" in the following example would have
checking enabled (the leading space character in the attribute's
value on the input
element causes the attribute to be
ignored, so the ancestor's value is used instead, regardless of the
default).
<p spellcheck="true"> <label>Name: <input spellcheck=" false" id="b"></label> </p>
This specification does not define the user interface for spelling and grammar checkers. A user agent could offer on-demand checking, could perform continuous checking while the checking is enabled, or could use other interfaces.