Make sure strikethrough can remove <strike>
authorAryeh Gregor <AryehGregor+gitcommit@gmail.com>
Tue, 12 Apr 2011 15:09:14 -0600
changeset 55 cdfb46b20f06
parent 54 b9b2593b33a9
child 56 c540bdbe5897
Make sure strikethrough can remove <strike>

It's what all browsers produce for it, after all. I didn't add the
ability to remove <del>, because browsers don't seem to do that.
autoimplementation.html
editcommands.html
implementation.js
preprocess
source.html
--- a/autoimplementation.html	Tue Apr 12 14:55:38 2011 -0600
+++ b/autoimplementation.html	Tue Apr 12 15:09:14 2011 -0600
@@ -771,6 +771,27 @@
 		'<s>foo[b<i>ar]ba</i>z</s>',
 		'<p style="text-decoration: line-through">foo[bar]baz</p>',
 
+		'foo<strike>[bar]</strike>baz',
+		'<strike>foo[bar]baz</strike>',
+		'<strike>foo[b<span style="color:red">ar]ba</span>z</strike>',
+		'<strike>foo[b<span style="color:red" id=foo>ar]ba</span>z</strike>',
+		'<strike>foo[b<span style="font-size:3em">ar]ba</span>z</strike>',
+		'<strike>foo[b<i>ar]ba</i>z</strike>',
+
+		'foo<ins>[bar]</ins>baz',
+		'<ins>foo[bar]baz</ins>',
+		'<ins>foo[b<span style="color:red">ar]ba</span>z</ins>',
+		'<ins>foo[b<span style="color:red" id=foo>ar]ba</span>z</ins>',
+		'<ins>foo[b<span style="font-size:3em">ar]ba</span>z</ins>',
+		'<ins>foo[b<i>ar]ba</i>z</ins>',
+
+		'foo<del>[bar]</del>baz',
+		'<del>foo[bar]baz</del>',
+		'<del>foo[b<span style="color:red">ar]ba</span>z</del>',
+		'<del>foo[b<span style="color:red" id=foo>ar]ba</span>z</del>',
+		'<del>foo[b<span style="font-size:3em">ar]ba</span>z</del>',
+		'<del>foo[b<i>ar]ba</i>z</del>',
+
 		'foo<span style="text-decoration: underline line-through">[bar]</span>baz',
 		'foo<span style="text-decoration: underline line-through">b[a]r</span>baz',
 		'foo<s style="text-decoration: underline">[bar]</s>baz',
@@ -885,6 +906,27 @@
 		'<s>foo[b<i>ar]ba</i>z</s>',
 		'<p style="text-decoration: line-through">foo[bar]baz</p>',
 
+		'foo<strike>[bar]</strike>baz',
+		'<strike>foo[bar]baz</strike>',
+		'<strike>foo[b<span style="color:red">ar]ba</span>z</strike>',
+		'<strike>foo[b<span style="color:red" id=foo>ar]ba</span>z</strike>',
+		'<strike>foo[b<span style="font-size:3em">ar]ba</span>z</strike>',
+		'<strike>foo[b<i>ar]ba</i>z</strike>',
+
+		'foo<ins>[bar]</ins>baz',
+		'<ins>foo[bar]baz</ins>',
+		'<ins>foo[b<span style="color:red">ar]ba</span>z</ins>',
+		'<ins>foo[b<span style="color:red" id=foo>ar]ba</span>z</ins>',
+		'<ins>foo[b<span style="font-size:3em">ar]ba</span>z</ins>',
+		'<ins>foo[b<i>ar]ba</i>z</ins>',
+
+		'foo<del>[bar]</del>baz',
+		'<del>foo[bar]baz</del>',
+		'<del>foo[b<span style="color:red">ar]ba</span>z</del>',
+		'<del>foo[b<span style="color:red" id=foo>ar]ba</span>z</del>',
+		'<del>foo[b<span style="font-size:3em">ar]ba</span>z</del>',
+		'<del>foo[b<i>ar]ba</i>z</del>',
+
 		'foo<span style="text-decoration: underline line-through">[bar]</span>baz',
 		'foo<span style="text-decoration: underline line-through">b[a]r</span>baz',
 		'foo<s style="text-decoration: underline">[bar]</s>baz',
--- a/editcommands.html	Tue Apr 12 14:55:38 2011 -0600
+++ b/editcommands.html	Tue Apr 12 15:09:14 2011 -0600
@@ -352,7 +352,7 @@
   </ol>
 
   <li>If <var title="">command</var> is "strikethrough" and <var title="">element</var> is an
-  <code class=external data-anolis-spec=html title="the s element"><a href=http://www.whatwg.org/html/#the-s-element>s</a></code> element, return "line-through".
+  <code class=external data-anolis-spec=html title="the s element"><a href=http://www.whatwg.org/html/#the-s-element>s</a></code> or <code class=external data-anolis-spec=html title="the strike element"><a href=http://www.whatwg.org/html/#the-strike-element>strike</a></code> element, return "line-through".
 
   <li>If <var title="">command</var> is "underline", and <var title="">element</var> has a
   <code class=external data-anolis-spec=html title="the style attribute"><a href=http://www.whatwg.org/html/#the-style-attribute>style</a></code> attribute set, and that attribute sets "text-decoration":
@@ -399,22 +399,23 @@
 </ol>
 
 <p>A <dfn id=modifiable-element>modifiable element</dfn> is a <code class=external data-anolis-spec=html title="the b element"><a href=http://www.whatwg.org/html/#the-b-element>b</a></code>, <code class=external data-anolis-spec=html title="the em element"><a href=http://www.whatwg.org/html/#the-em-element>em</a></code>, <code class=external data-anolis-spec=html title="the i element"><a href=http://www.whatwg.org/html/#the-i-element>i</a></code>, <code class=external data-anolis-spec=html title="the s element"><a href=http://www.whatwg.org/html/#the-s-element>s</a></code>, <code class=external data-anolis-spec=html title="the span element"><a href=http://www.whatwg.org/html/#the-span-element>span</a></code>,
-<code class=external data-anolis-spec=html title="the strong element"><a href=http://www.whatwg.org/html/#the-strong-element>strong</a></code>, <code class=external data-anolis-spec=html title="the sub and sup elements"><a href=http://www.whatwg.org/html/#the-sub-and-sup-elements>sub</a></code>, <code class=external data-anolis-spec=html title="the sub and sup elements"><a href=http://www.whatwg.org/html/#the-sub-and-sup-elements>sup</a></code>, or <code class=external data-anolis-spec=html title="the u element"><a href=http://www.whatwg.org/html/#the-u-element>u</a></code> element with no attributes except
-possibly <code class=external data-anolis-spec=html title="the style attribute"><a href=http://www.whatwg.org/html/#the-style-attribute>style</a></code>; or a <code class=external data-anolis-spec=html title=font><a href=http://www.whatwg.org/html/#font>font</a></code> element with no attributes except possibly
-<code class=external data-anolis-spec=html title="the style attribute"><a href=http://www.whatwg.org/html/#the-style-attribute>style</a></code>, <code class=external data-anolis-spec=html title=dom-font-color><a href=http://www.whatwg.org/html/#dom-font-color>color</a></code>, <code class=external data-anolis-spec=html title=dom-font-face><a href=http://www.whatwg.org/html/#dom-font-face>face</a></code>, and/or <code class=external data-anolis-spec=html title=dom-font-size><a href=http://www.whatwg.org/html/#dom-font-size>size</a></code>; or an <code class=external data-anolis-spec=html title="the a element"><a href=http://www.whatwg.org/html/#the-a-element>a</a></code>
-element with no attributes except possibly <code class=external data-anolis-spec=html title="the style attribute"><a href=http://www.whatwg.org/html/#the-style-attribute>style</a></code> and/or <code class=external data-anolis-spec=html title=attr-hyperlink-href><a href=http://www.whatwg.org/html/#attr-hyperlink-href>href</a></code>.
+<code class=external data-anolis-spec=html title="the strike element"><a href=http://www.whatwg.org/html/#the-strike-element>strike</a></code>, <code class=external data-anolis-spec=html title="the strong element"><a href=http://www.whatwg.org/html/#the-strong-element>strong</a></code>, <code class=external data-anolis-spec=html title="the sub and sup elements"><a href=http://www.whatwg.org/html/#the-sub-and-sup-elements>sub</a></code>, <code class=external data-anolis-spec=html title="the sub and sup elements"><a href=http://www.whatwg.org/html/#the-sub-and-sup-elements>sup</a></code>, or <code class=external data-anolis-spec=html title="the u element"><a href=http://www.whatwg.org/html/#the-u-element>u</a></code> element with no attributes
+except possibly <code class=external data-anolis-spec=html title="the style attribute"><a href=http://www.whatwg.org/html/#the-style-attribute>style</a></code>; or a <code class=external data-anolis-spec=html title=font><a href=http://www.whatwg.org/html/#font>font</a></code> element with no attributes except
+possibly <code class=external data-anolis-spec=html title="the style attribute"><a href=http://www.whatwg.org/html/#the-style-attribute>style</a></code>, <code class=external data-anolis-spec=html title=dom-font-color><a href=http://www.whatwg.org/html/#dom-font-color>color</a></code>, <code class=external data-anolis-spec=html title=dom-font-face><a href=http://www.whatwg.org/html/#dom-font-face>face</a></code>, and/or <code class=external data-anolis-spec=html title=dom-font-size><a href=http://www.whatwg.org/html/#dom-font-size>size</a></code>; or an
+<code class=external data-anolis-spec=html title="the a element"><a href=http://www.whatwg.org/html/#the-a-element>a</a></code> element with no attributes except possibly <code class=external data-anolis-spec=html title="the style attribute"><a href=http://www.whatwg.org/html/#the-style-attribute>style</a></code> and/or <code class=external data-anolis-spec=html title=attr-hyperlink-href><a href=http://www.whatwg.org/html/#attr-hyperlink-href>href</a></code>.
 
 <p>A <dfn id=simple-modifiable-element>simple modifiable element</dfn> is an <a href=#html-element>HTML element</a> for
 which at least one of the following holds:
 
 <ul>
   <li>It is an <code class=external data-anolis-spec=html title="the a element"><a href=http://www.whatwg.org/html/#the-a-element>a</a></code>, <code class=external data-anolis-spec=html title="the b element"><a href=http://www.whatwg.org/html/#the-b-element>b</a></code>, <code class=external data-anolis-spec=html title="the em element"><a href=http://www.whatwg.org/html/#the-em-element>em</a></code>, <code class=external data-anolis-spec=html title=font><a href=http://www.whatwg.org/html/#font>font</a></code>, <code class=external data-anolis-spec=html title="the i element"><a href=http://www.whatwg.org/html/#the-i-element>i</a></code>, <code class=external data-anolis-spec=html title="the s element"><a href=http://www.whatwg.org/html/#the-s-element>s</a></code>, <code class=external data-anolis-spec=html title="the span element"><a href=http://www.whatwg.org/html/#the-span-element>span</a></code>,
-  <code class=external data-anolis-spec=html title="the strong element"><a href=http://www.whatwg.org/html/#the-strong-element>strong</a></code>, <code class=external data-anolis-spec=html title="the sub and sup elements"><a href=http://www.whatwg.org/html/#the-sub-and-sup-elements>sub</a></code>, <code class=external data-anolis-spec=html title="the sub and sup elements"><a href=http://www.whatwg.org/html/#the-sub-and-sup-elements>sup</a></code>, or <code class=external data-anolis-spec=html title="the u element"><a href=http://www.whatwg.org/html/#the-u-element>u</a></code> element with no attributes.
+  <code class=external data-anolis-spec=html title="the strike element"><a href=http://www.whatwg.org/html/#the-strike-element>strike</a></code>, <code class=external data-anolis-spec=html title="the strong element"><a href=http://www.whatwg.org/html/#the-strong-element>strong</a></code>, <code class=external data-anolis-spec=html title="the sub and sup elements"><a href=http://www.whatwg.org/html/#the-sub-and-sup-elements>sub</a></code>, <code class=external data-anolis-spec=html title="the sub and sup elements"><a href=http://www.whatwg.org/html/#the-sub-and-sup-elements>sup</a></code>, or <code class=external data-anolis-spec=html title="the u element"><a href=http://www.whatwg.org/html/#the-u-element>u</a></code> element with no
+  attributes.
 
   <li>It is an <code class=external data-anolis-spec=html title="the a element"><a href=http://www.whatwg.org/html/#the-a-element>a</a></code>, <code class=external data-anolis-spec=html title="the b element"><a href=http://www.whatwg.org/html/#the-b-element>b</a></code>, <code class=external data-anolis-spec=html title="the em element"><a href=http://www.whatwg.org/html/#the-em-element>em</a></code>, <code class=external data-anolis-spec=html title=font><a href=http://www.whatwg.org/html/#font>font</a></code>, <code class=external data-anolis-spec=html title="the i element"><a href=http://www.whatwg.org/html/#the-i-element>i</a></code>, <code class=external data-anolis-spec=html title="the s element"><a href=http://www.whatwg.org/html/#the-s-element>s</a></code>, <code class=external data-anolis-spec=html title="the span element"><a href=http://www.whatwg.org/html/#the-span-element>span</a></code>,
-  <code class=external data-anolis-spec=html title="the strong element"><a href=http://www.whatwg.org/html/#the-strong-element>strong</a></code>, <code class=external data-anolis-spec=html title="the sub and sup elements"><a href=http://www.whatwg.org/html/#the-sub-and-sup-elements>sub</a></code>, <code class=external data-anolis-spec=html title="the sub and sup elements"><a href=http://www.whatwg.org/html/#the-sub-and-sup-elements>sup</a></code>, or <code class=external data-anolis-spec=html title="the u element"><a href=http://www.whatwg.org/html/#the-u-element>u</a></code> element with exactly one attribute,
-  which is <code class=external data-anolis-spec=html title="the style attribute"><a href=http://www.whatwg.org/html/#the-style-attribute>style</a></code>, which sets no CSS properties (including invalid or
-  unrecognized properties).
+  <code class=external data-anolis-spec=html title="the strike element"><a href=http://www.whatwg.org/html/#the-strike-element>strike</a></code>, <code class=external data-anolis-spec=html title="the strong element"><a href=http://www.whatwg.org/html/#the-strong-element>strong</a></code>, <code class=external data-anolis-spec=html title="the sub and sup elements"><a href=http://www.whatwg.org/html/#the-sub-and-sup-elements>sub</a></code>, <code class=external data-anolis-spec=html title="the sub and sup elements"><a href=http://www.whatwg.org/html/#the-sub-and-sup-elements>sup</a></code>, or <code class=external data-anolis-spec=html title="the u element"><a href=http://www.whatwg.org/html/#the-u-element>u</a></code> element with exactly one
+  attribute, which is <code class=external data-anolis-spec=html title="the style attribute"><a href=http://www.whatwg.org/html/#the-style-attribute>style</a></code>, which sets no CSS properties (including
+  invalid or unrecognized properties).
 
   <li>It is an <code class=external data-anolis-spec=html title="the a element"><a href=http://www.whatwg.org/html/#the-a-element>a</a></code> element with exactly one attribute, which is <code class=external data-anolis-spec=html title=attr-hyperlink-href><a href=http://www.whatwg.org/html/#attr-hyperlink-href>href</a></code>.
 
@@ -438,10 +439,10 @@
   (including invalid or unrecognized properties), and that property is not
   "text-decoration".
 
-  <li>It is an <code class=external data-anolis-spec=html title="the a element"><a href=http://www.whatwg.org/html/#the-a-element>a</a></code>, <code class=external data-anolis-spec=html title=font><a href=http://www.whatwg.org/html/#font>font</a></code>, <code class=external data-anolis-spec=html title="the s element"><a href=http://www.whatwg.org/html/#the-s-element>s</a></code>, <code class=external data-anolis-spec=html title="the span element"><a href=http://www.whatwg.org/html/#the-span-element>span</a></code>, or <code class=external data-anolis-spec=html title="the u element"><a href=http://www.whatwg.org/html/#the-u-element>u</a></code> element with exactly
-  one attribute, which is <code class=external data-anolis-spec=html title="the style attribute"><a href=http://www.whatwg.org/html/#the-style-attribute>style</a></code>, and the <code class=external data-anolis-spec=html title="the style attribute"><a href=http://www.whatwg.org/html/#the-style-attribute>style</a></code> attribute sets exactly
-  one CSS property (including invalid or unrecognized properties), which is
-  "text-decoration", which is set to "line-through" or "underline" or
+  <li>It is an <code class=external data-anolis-spec=html title="the a element"><a href=http://www.whatwg.org/html/#the-a-element>a</a></code>, <code class=external data-anolis-spec=html title=font><a href=http://www.whatwg.org/html/#font>font</a></code>, <code class=external data-anolis-spec=html title="the s element"><a href=http://www.whatwg.org/html/#the-s-element>s</a></code>, <code class=external data-anolis-spec=html title="the span element"><a href=http://www.whatwg.org/html/#the-span-element>span</a></code>, <code class=external data-anolis-spec=html title="the strike element"><a href=http://www.whatwg.org/html/#the-strike-element>strike</a></code>, or <code class=external data-anolis-spec=html title="the u element"><a href=http://www.whatwg.org/html/#the-u-element>u</a></code> element
+  with exactly one attribute, which is <code class=external data-anolis-spec=html title="the style attribute"><a href=http://www.whatwg.org/html/#the-style-attribute>style</a></code>, and the <code class=external data-anolis-spec=html title="the style attribute"><a href=http://www.whatwg.org/html/#the-style-attribute>style</a></code> attribute
+  sets exactly one CSS property (including invalid or unrecognized properties),
+  which is "text-decoration", which is set to "line-through" or "underline" or
   "overline" or "none".
 </ul>
 
--- a/implementation.js	Tue Apr 12 14:55:38 2011 -0600
+++ b/implementation.js	Tue Apr 12 15:09:14 2011 -0600
@@ -561,11 +561,11 @@
 		return null;
 	}
 
-	// "If command is "strikethrough" and element is a s element, return
-	// "line-through"."
+	// "If command is "strikethrough" and element is a s or strike element,
+	// return "line-through"."
 	if (command == "strikethrough"
 	&& isHtmlElement(element)
-	&& element.tagName == "S") {
+	&& (element.tagName == "S" || element.tagName == "STRIKE")) {
 		return "line-through";
 	}
 
@@ -664,7 +664,7 @@
 		return false;
 	}
 
-	if (["B", "EM", "I", "S", "SPAN", "STRONG", "SUB", "SUP", "U"].indexOf(node.tagName) != -1) {
+	if (["B", "EM", "I", "S", "SPAN", "STRIKE", "STRONG", "SUB", "SUP", "U"].indexOf(node.tagName) != -1) {
 		if (node.attributes.length == 0) {
 			return true;
 		}
@@ -717,12 +717,12 @@
 	}
 
 	// Only these elements can possibly be a simple modifiable element.
-	if (["A", "B", "EM", "FONT", "I", "S", "SPAN", "STRONG", "SUB", "SUP", "U"].indexOf(node.tagName) == -1) {
+	if (["A", "B", "EM", "FONT", "I", "S", "SPAN", "STRIKE", "STRONG", "SUB", "SUP", "U"].indexOf(node.tagName) == -1) {
 		return false;
 	}
 
-	// "It is an a, b, em, font, i, s, span, strong, sub, sup, or u element
-	// with no attributes."
+	// "It is an a, b, em, font, i, s, span, strike, strong, sub, sup, or u
+	// element with no attributes."
 	if (node.attributes.length == 0) {
 		return true;
 	}
@@ -732,9 +732,9 @@
 		return false;
 	}
 
-	// "It is an a, b, em, font, i, s, span, strong, sub, sup, or u element
-	// with exactly one attribute, which is style, which sets no CSS properties
-	// (including invalid or unrecognized properties)."
+	// "It is an a, b, em, font, i, s, span, strike, strong, sub, sup, or u
+	// element with exactly one attribute, which is style, which sets no CSS
+	// properties (including invalid or unrecognized properties)."
 	//
 	// Not gonna try for invalid or unrecognized.
 	if (node.hasAttribute("style")
@@ -799,12 +799,12 @@
 		return true;
 	}
 
-	// "It is an a, font, s, span, or u element with exactly one attribute,
-	// which is style, and the style attribute sets exactly one CSS property
-	// (including invalid or unrecognized properties), which is
+	// "It is an a, font, s, span, strike, or u element with exactly one
+	// attribute, which is style, and the style attribute sets exactly one CSS
+	// property (including invalid or unrecognized properties), which is
 	// "text-decoration", which is set to "line-through" or "underline" or
 	// "overline" or "none"."
-	if (["A", "FONT", "S", "SPAN", "U"].indexOf(node.tagName) != -1
+	if (["A", "FONT", "S", "SPAN", "STRIKE", "U"].indexOf(node.tagName) != -1
 	&& node.hasAttribute("style")
 	&& node.style.length == 1
 	&& (node.style.textDecoration == "line-through"
--- a/preprocess	Tue Apr 12 14:55:38 2011 -0600
+++ b/preprocess	Tue Apr 12 15:09:14 2011 -0600
@@ -56,6 +56,7 @@
     'selection': '<code data-anolis-spec=domrange>Selection</code>',
     'sibling': '<span data-anolis-spec=domcore title=concept-tree-sibling>sibling</span>',
     'span': '<code data-anolis-spec=html title="the span element">span</code>',
+    'strike': '<code data-anolis-spec=html title="the strike element">strike</code>',
     'strong': '<code data-anolis-spec=html title="the strong element">strong</code>',
     'style': '<code data-anolis-spec=html title="the style attribute">style</code>',
     'sub': '<code data-anolis-spec=html title="the sub and sup elements">sub</code>',
--- a/source.html	Tue Apr 12 14:55:38 2011 -0600
+++ b/source.html	Tue Apr 12 15:09:14 2011 -0600
@@ -341,7 +341,7 @@
   </ol>
 
   <li>If <var>command</var> is "strikethrough" and <var>element</var> is an
-  [[s]] element, return "line-through".
+  [[s]] or [[strike]] element, return "line-through".
 
   <li>If <var>command</var> is "underline", and <var>element</var> has a
   [[style]] attribute set, and that attribute sets "text-decoration":
@@ -388,22 +388,23 @@
 </ol>
 
 <p>A <dfn>modifiable element</dfn> is a [[b]], [[em]], [[i]], [[s]], [[span]],
-[[strong]], [[sub]], [[sup]], or [[u]] element with no attributes except
-possibly [[style]]; or a [[font]] element with no attributes except possibly
-[[style]], [[fontcolor]], [[fontface]], and/or [[fontsize]]; or an [[a]]
-element with no attributes except possibly [[style]] and/or [[href]].
+[[strike]], [[strong]], [[sub]], [[sup]], or [[u]] element with no attributes
+except possibly [[style]]; or a [[font]] element with no attributes except
+possibly [[style]], [[fontcolor]], [[fontface]], and/or [[fontsize]]; or an
+[[a]] element with no attributes except possibly [[style]] and/or [[href]].
 
 <p>A <dfn>simple modifiable element</dfn> is an <span>HTML element</span> for
 which at least one of the following holds:
 
 <ul>
   <li>It is an [[a]], [[b]], [[em]], [[font]], [[i]], [[s]], [[span]],
-  [[strong]], [[sub]], [[sup]], or [[u]] element with no attributes.
+  [[strike]], [[strong]], [[sub]], [[sup]], or [[u]] element with no
+  attributes.
 
   <li>It is an [[a]], [[b]], [[em]], [[font]], [[i]], [[s]], [[span]],
-  [[strong]], [[sub]], [[sup]], or [[u]] element with exactly one attribute,
-  which is [[style]], which sets no CSS properties (including invalid or
-  unrecognized properties).
+  [[strike]], [[strong]], [[sub]], [[sup]], or [[u]] element with exactly one
+  attribute, which is [[style]], which sets no CSS properties (including
+  invalid or unrecognized properties).
 
   <li>It is an [[a]] element with exactly one attribute, which is [[href]].
 
@@ -427,10 +428,10 @@
   (including invalid or unrecognized properties), and that property is not
   "text-decoration".
 
-  <li>It is an [[a]], [[font]], [[s]], [[span]], or [[u]] element with exactly
-  one attribute, which is [[style]], and the [[style]] attribute sets exactly
-  one CSS property (including invalid or unrecognized properties), which is
-  "text-decoration", which is set to "line-through" or "underline" or
+  <li>It is an [[a]], [[font]], [[s]], [[span]], [[strike]], or [[u]] element
+  with exactly one attribute, which is [[style]], and the [[style]] attribute
+  sets exactly one CSS property (including invalid or unrecognized properties),
+  which is "text-decoration", which is set to "line-through" or "underline" or
   "overline" or "none".
 </ul>