Fix myQueryCommandEnabled() bugs
authorAryeh Gregor <AryehGregor+gitcommit@gmail.com>
Thu, 07 Jul 2011 13:45:19 -0600
changeset 368 1f8c4dd6e377
parent 367 8d6c424b650c
child 369 5434609f3f5d
Fix myQueryCommandEnabled() bugs
implementation.js
--- a/implementation.js	Thu Jul 07 13:32:42 2011 -0600
+++ b/implementation.js	Thu Jul 07 13:45:19 2011 -0600
@@ -544,7 +544,8 @@
 	// exception."
 	// "If command has no state, raise an INVALID_ACCESS_ERR exception."
 	// "If command has no value, raise an INVALID_ACCESS_ERR exception."
-	if (!(prop in commands[command])) {
+	if (prop != "enabled"
+	&& !(prop in commands[command])) {
 		throw "INVALID_ACCESS_ERR";
 	}
 }
@@ -594,9 +595,7 @@
 	command = command.toLowerCase();
 
 	// "If command is not supported, raise a NOT_SUPPORTED_ERR exception."
-	if (!(command in commands)) {
-		throw "NOT_SUPPORTED_ERR";
-	}
+	setupEditCommandMethod(command, "action", range);
 
 	// "Return true if command is enabled, false otherwise."
 	//
@@ -610,7 +609,7 @@
 		return true;
 	}
 
-	return getActiveRange()
+	return Boolean(getActiveRange()
 	&& (getAllEffectivelyContainedNodes(getActiveRange(), function(node) {
 		return isEditingHost(node)
 			|| getAncestors(node).some(isEditingHost);
@@ -618,7 +617,7 @@
 	|| isEditingHost(getActiveRange().startContainer)
 	|| getAncestors(getActiveRange().startContainer).some(isEditingHost)
 	|| isEditingHost(getActiveRange().endContainer)
-	|| getAncestors(getActiveRange().endContainer).some(isEditingHost));
+	|| getAncestors(getActiveRange().endContainer).some(isEditingHost)));
 }
 
 function myQueryCommandIndeterm(command, range) {