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

Unified Diff: ui/webui/resources/cr_elements/cr_search_field/cr_search_field_behavior.js

Issue 2180843006: MD WebUI: Remove local DOM access from CrSearchFieldBehavior (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cr_search_field_clear
Patch Set: Vulcanize Created 4 years, 5 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
Index: ui/webui/resources/cr_elements/cr_search_field/cr_search_field_behavior.js
diff --git a/ui/webui/resources/cr_elements/cr_search_field/cr_search_field_behavior.js b/ui/webui/resources/cr_elements/cr_search_field/cr_search_field_behavior.js
index d6a68d5919f0a622933cadaf8c3a1f65d3c0a3f5..51304c0b2af870166ce30f168e1ea999478440f0 100644
--- a/ui/webui/resources/cr_elements/cr_search_field/cr_search_field_behavior.js
+++ b/ui/webui/resources/cr_elements/cr_search_field/cr_search_field_behavior.js
@@ -35,10 +35,17 @@ var CrSearchFieldBehavior = {
},
/**
+ * @abstract
+ * @return {!HTMLInputElement} The input field element the behavior should
+ * use.
+ */
+ getSearchInput: function() {},
+
+ /**
* @return {string} The value of the search field.
*/
getValue: function() {
- return this.$.searchInput.value;
+ return this.getSearchInput().value;
},
/**
@@ -48,7 +55,7 @@ var CrSearchFieldBehavior = {
setValue: function(value) {
// Use bindValue when setting the input value so that changes propagate
// correctly.
- this.$.searchInput.bindValue = value;
+ this.getSearchInput().bindValue = value;
this.onValueChanged_(value);
},
@@ -59,7 +66,7 @@ var CrSearchFieldBehavior = {
/** @private */
focus_: function() {
- this.$.searchInput.focus();
+ this.getSearchInput().focus();
},
onSearchTermSearch: function() {
@@ -93,11 +100,6 @@ var CrSearchFieldBehavior = {
}
this.setValue('');
- this.$.searchInput.blur();
- },
-
- /** @return {boolean} */
- isSearchFocused: function() {
- return this.$.searchTerm.focused;
+ this.getSearchInput().blur();
}
};

Powered by Google App Engine
This is Rietveld 408576698