Index: chrome/browser/resources/print_preview/settings/advanced_settings/advanced_settings_item.js |
diff --git a/chrome/browser/resources/print_preview/settings/advanced_settings/advanced_settings_item.js b/chrome/browser/resources/print_preview/settings/advanced_settings/advanced_settings_item.js |
index 7e189922a228ab04151cda1be26bac09ed8d417b..6ca060973d41acfad19ea843111b2cb180e483d4 100644 |
--- a/chrome/browser/resources/print_preview/settings/advanced_settings/advanced_settings_item.js |
+++ b/chrome/browser/resources/print_preview/settings/advanced_settings/advanced_settings_item.js |
@@ -1,30 +1,40 @@ |
// Copyright 2014 The Chromium Authors. All rights reserved. |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
+/** |
+ * Specifies a custom vendor capability. |
+ * @typedef {{ |
+ * id: (string), |
+ * display_name: (string), |
+ * localized_display_name: (string | undefined), |
+ * type: (string), |
+ * select_cap: ({ |
+ * option: (Array<{ |
+ * display_name: (string), |
+ * type: (string | undefined), |
+ * value: (number | string | boolean), |
+ * is_default: (boolean | undefined) |
+ * }>|undefined) |
+ * }|undefined) |
+ * }} |
+ */ |
+print_preview.VendorCapability; |
cr.define('print_preview', function() { |
'use strict'; |
/** |
* Component that renders a destination item in a destination list. |
- * @param {!cr.EventTarget} eventTarget Event target to dispatch selection |
- * events to. |
* @param {!print_preview.PrintTicketStore} printTicketStore Contains the |
* print ticket to print. |
- * @param {!Object} capability Capability to render. |
+ * @param {!print_preview.VendorCapability} capability Capability to render. |
* @constructor |
* @extends {print_preview.Component} |
*/ |
- function AdvancedSettingsItem(eventTarget, printTicketStore, capability) { |
+ function AdvancedSettingsItem(printTicketStore, capability) { |
print_preview.Component.call(this); |
/** |
- * Event target to dispatch selection events to. |
- * @private {!cr.EventTarget} |
- */ |
- this.eventTarget_ = eventTarget; |
- |
- /** |
* Contains the print ticket to print. |
* @private {!print_preview.PrintTicketStore} |
*/ |
@@ -32,7 +42,7 @@ cr.define('print_preview', function() { |
/** |
* Capability this component renders. |
- * @private {!Object} |
+ * @private {!print_preview.VendorCapability} |
*/ |
this.capability_ = capability; |
@@ -58,7 +68,7 @@ cr.define('print_preview', function() { |
/** @private {!EventTracker} */ |
this.tracker_ = new EventTracker(); |
- }; |
+ } |
AdvancedSettingsItem.prototype = { |
__proto__: print_preview.Component.prototype, |
@@ -69,8 +79,9 @@ cr.define('print_preview', function() { |
'advanced-settings-item-template')); |
this.tracker_.add( |
- this.select_, 'change', this.onSelectChange_.bind(this)); |
- this.tracker_.add(this.text_, 'input', this.onTextInput_.bind(this)); |
+ assert(this.select_), 'change', this.onSelectChange_.bind(this)); |
+ this.tracker_.add( |
+ assert(this.text_), 'input', this.onTextInput_.bind(this)); |
this.initializeValue_(); |
@@ -116,8 +127,8 @@ cr.define('print_preview', function() { |
* @private |
*/ |
get select_() { |
- return this.getChildElement( |
- '.advanced-settings-item-value-select-control'); |
+ return /** @type {HTMLSelectElement} */( |
+ this.getChildElement('.advanced-settings-item-value-select-control')); |
}, |
/** |
@@ -125,7 +136,8 @@ cr.define('print_preview', function() { |
* @private |
*/ |
get text_() { |
- return this.getChildElement('.advanced-settings-item-value-text-control'); |
+ return /** @type {HTMLSelectElement} */( |
dpapad
2017/05/04 01:20:04
How about casting to !HTMLSelectElement here, and
rbpotter
2017/05/04 01:43:07
Done.
|
+ this.getChildElement('.advanced-settings-item-value-text-control')); |
}, |
/** |
@@ -256,8 +268,8 @@ cr.define('print_preview', function() { |
* @private |
*/ |
initializeSelectValue_: function() { |
- setIsVisible( |
- this.getChildElement('.advanced-settings-item-value-select'), true); |
+ setIsVisible(assert(this.getChildElement( |
+ '.advanced-settings-item-value-select')), true); |
var selectEl = this.select_; |
var indexToSelect = 0; |
this.capability_.select_cap.option.forEach(function(option, index) { |
@@ -282,8 +294,8 @@ cr.define('print_preview', function() { |
* @private |
*/ |
initializeTextValue_: function() { |
- setIsVisible( |
- this.getChildElement('.advanced-settings-item-value-text'), true); |
+ setIsVisible(assert(this.getChildElement( |
+ '.advanced-settings-item-value-text')), true); |
var defaultValue = null; |
if (this.capability_.type == 'TYPED_VALUE' && |