Remove residual complexity from insertImage
authorAryeh Gregor <AryehGregor+gitcommit@gmail.com>
Mon, 16 May 2011 13:23:48 -0600
changeset 124 818c3e2af710
parent 123 558bb41b3307
child 125 7724c3ee154a
Remove residual complexity from insertImage
editcommands.html
implementation.js
source.html
--- a/editcommands.html	Mon May 16 12:44:21 2011 -0600
+++ b/editcommands.html	Mon May 16 13:23:48 2011 -0600
@@ -2402,15 +2402,8 @@
 
   <li>Run <code class=external data-anolis-spec=domrange title=dom-Range-deleteContents><a href=http://html5.org/specs/dom-range.html#dom-range-deletecontents>deleteContents()</a></code> on the <a class=external data-anolis-spec=domrange href=http://html5.org/specs/dom-range.html#concept-range title=concept-range>range</a>.
 
-  <li>Let (<var title="">node</var>, <var title="">offset</var>) be the <a class=external data-anolis-spec=domrange href=http://html5.org/specs/dom-range.html#concept-range title=concept-range>range</a>'s
-  <a class=external data-anolis-spec=domrange href=http://html5.org/specs/dom-range.html#concept-range-start title=concept-range-start>start</a>.
-
-  <li>If <var title="">node</var> is a <code class=external data-anolis-spec=domcore><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#text>Text</a></code> or <code class=external data-anolis-spec=domcore><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#comment>Comment</a></code> node and its <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-parent title=concept-tree-parent>parent</a>
-  is null, abort these steps and do nothing.
-
   <li>Let <var title="">img</var> be the result of calling <code class=external data-anolis-spec=domcore title=dom-Document-createElement><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-document-createelement>createElement("img")</a></code> on the
-  <code class=external data-anolis-spec=domcore title=dom-Node-ownerDocument><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-node-ownerdocument>ownerDocument</a></code> of <var title="">node</var> (or on <var title="">node</var> itself if it's a
-  <code class=external data-anolis-spec=domcore><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#document>Document</a></code>).
+  <a class=external data-anolis-spec=domrange href=http://html5.org/specs/dom-range.html#context-object>context object</a>.
 
   <li>Run <code class=external data-anolis-spec=domcore title=dom-Element-setAttribute><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-element-setattribute>setAttribute("src", <var title="">value</var>)</a></code>
   on <var title="">img</var>.
--- a/implementation.js	Mon May 16 12:44:21 2011 -0600
+++ b/implementation.js	Mon May 16 13:23:48 2011 -0600
@@ -2489,22 +2489,9 @@
 		// "Run deleteContents() on the range."
 		range.deleteContents();
 
-		// "Let (node, offset) be the range's start."
-		var node = range.startContainer;
-		var offset = range.startOffset;
-
-		// "If node is a Text or Comment node and its parent is null, abort
-		// these steps and do nothing."
-		if (!node.parentNode
-		&& (node.nodeType == Node.TEXT_NODE
-		|| node.nodeType == Node.COMMENT_NODE)) {
-			return;
-		}
-
 		// "Let img be the result of calling createElement("img") on the
-		// ownerDocument of node (or on node itself if it's a Document)."
-		var img = (node.nodeType == Node.DOCUMENT_NODE
-			? node : node.ownerDocument).createElement("img");
+		// context object."
+		var img = document.createElement("img");
 
 		// "Run setAttribute("src", value) on img."
 		img.setAttribute("src", value);
--- a/source.html	Mon May 16 12:44:21 2011 -0600
+++ b/source.html	Mon May 16 13:23:48 2011 -0600
@@ -2438,17 +2438,10 @@
   <li>Run <code data-anolis-spec=domrange
   title=dom-Range-deleteContents>deleteContents()</code> on the [[range]].
 
-  <li>Let (<var>node</var>, <var>offset</var>) be the [[range]]'s
-  [[rangestart]].
-
-  <li>If <var>node</var> is a [[text]] or [[comment]] node and its [[parent]]
-  is null, abort these steps and do nothing.
-
   <li>Let <var>img</var> be the result of calling <code
   data-anolis-spec=domcore
   title=dom-Document-createElement>createElement("img")</code> on the
-  [[ownerdocument]] of <var>node</var> (or on <var>node</var> itself if it's a
-  [[document]]).
+  [[contextobject]].
 
   <li>Run <code data-anolis-spec=domcore
   title=dom-Element-setAttribute>setAttribute("src", <var>value</var>)</code>