Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1224)

Unified Diff: Source/devtools/front_end/components/ObjectPropertiesSection.js

Issue 323423002: DevTools: Deleting object property in console would just assign it to undefined. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/devtools/front_end/sdk/RemoteObject.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/devtools/front_end/components/ObjectPropertiesSection.js
diff --git a/Source/devtools/front_end/components/ObjectPropertiesSection.js b/Source/devtools/front_end/components/ObjectPropertiesSection.js
index 4481f356dcea5448e890590eb03b875f4286f7ad..442623fea6c9ecb644a0e463c8d4c09642ae1dfc 100644
--- a/Source/devtools/front_end/components/ObjectPropertiesSection.js
+++ b/Source/devtools/front_end/components/ObjectPropertiesSection.js
@@ -298,12 +298,14 @@ WebInspector.ObjectPropertyTreeElement.prototype = {
},
/**
- * @param {!Event=} event
- * @return {!Array.<!Element|undefined>}
+ * @return {{element: !Element, value: (string|undefined)}}
*/
- elementAndValueToEdit: function(event)
+ elementAndValueToEdit: function()
{
- return [this.valueElement, (typeof this.valueElement._originalTextContent === "string") ? this.valueElement._originalTextContent : undefined];
+ return {
+ element: this.valueElement,
+ value: (typeof this.valueElement._originalTextContent === "string") ? this.valueElement._originalTextContent : undefined
+ };
},
/**
@@ -311,9 +313,9 @@ WebInspector.ObjectPropertyTreeElement.prototype = {
*/
startEditing: function(event)
{
- var elementAndValueToEdit = this.elementAndValueToEdit(event);
- var elementToEdit = elementAndValueToEdit[0];
- var valueToEdit = elementAndValueToEdit[1];
+ var elementAndValueToEdit = this.elementAndValueToEdit();
+ var elementToEdit = elementAndValueToEdit.element;
+ var valueToEdit = elementAndValueToEdit.value;
if (WebInspector.isBeingEdited(elementToEdit) || !this.treeOutline.section.editable || this._readOnly)
return;
@@ -377,7 +379,7 @@ WebInspector.ObjectPropertyTreeElement.prototype = {
}
this.editingEnded(context);
- this.applyExpression(userInput, true);
+ this.applyExpression(userInput);
},
_promptKeyDown: function(context, event)
@@ -394,10 +396,16 @@ WebInspector.ObjectPropertyTreeElement.prototype = {
}
},
- applyExpression: function(expression, updateInterface)
+ /**
+ * @param {string} expression
+ */
+ applyExpression: function(expression)
{
expression = expression.trim();
- var expressionLength = expression.length;
+ if (expression)
+ this.property.parentObject.setPropertyValue(this.property.name, expression, callback.bind(this));
+ else
+ this.property.parentObject.deleteProperty(this.property.name, callback.bind(this));
/**
* @param {?Protocol.Error} error
@@ -405,13 +413,12 @@ WebInspector.ObjectPropertyTreeElement.prototype = {
*/
function callback(error)
{
- if (!updateInterface)
- return;
-
- if (error)
+ if (error) {
this.update();
+ return;
+ }
- if (!expressionLength) {
+ if (!expression) {
// The property was deleted, so remove this tree element.
this.parent.removeChild(this);
} else {
@@ -419,7 +426,6 @@ WebInspector.ObjectPropertyTreeElement.prototype = {
this.updateSiblings();
}
};
- this.property.parentObject.setPropertyValue(this.property.name, expression.trim(), callback.bind(this));
},
/**
« no previous file with comments | « no previous file | Source/devtools/front_end/sdk/RemoteObject.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698