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

Side by Side Diff: third_party/polymer/v1_0/components-chromium/iron-behaviors/iron-control-state-extracted.js

Issue 1187823002: Update Polymer components and re-run reproduce.sh (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 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 unified diff | Download patch
OLDNEW
1 1
2 2
3 /** @polymerBehavior */ 3 /**
4 4 * @demo demo/index.html
5 * @polymerBehavior
6 */
5 Polymer.IronControlState = { 7 Polymer.IronControlState = {
6 8
7 properties: { 9 properties: {
8 10
9 /** 11 /**
10 * If true, the element currently has focus. 12 * If true, the element currently has focus.
11 *
12 * @attribute focused
13 * @type boolean
14 * @default false
15 */ 13 */
16 focused: { 14 focused: {
17 type: Boolean, 15 type: Boolean,
18 value: false, 16 value: false,
19 notify: true, 17 notify: true,
20 readOnly: true, 18 readOnly: true,
21 reflectToAttribute: true 19 reflectToAttribute: true
22 }, 20 },
23 21
24 /** 22 /**
25 * If true, the user cannot interact with this element. 23 * If true, the user cannot interact with this element.
26 *
27 * @attribute disabled
28 * @type boolean
29 * @default false
30 */ 24 */
31 disabled: { 25 disabled: {
32 type: Boolean, 26 type: Boolean,
33 value: false, 27 value: false,
34 notify: true, 28 notify: true,
35 observer: '_disabledChanged', 29 observer: '_disabledChanged',
36 reflectToAttribute: true 30 reflectToAttribute: true
37 }, 31 },
38 32
39 _oldTabIndex: { 33 _oldTabIndex: {
40 type: Number 34 type: Number
35 },
36
37 _boundFocusBlurHandler: {
38 type: Function,
39 value: function() {
40 return this._focusBlurHandler.bind(this);
41 }
41 } 42 }
43
42 }, 44 },
43 45
44 observers: [ 46 observers: [
45 '_changedControlState(focused, disabled)' 47 '_changedControlState(focused, disabled)'
46 ], 48 ],
47 49
48 listeners: {
49 focus: '_focusHandler',
50 blur: '_blurHandler'
51 },
52
53 ready: function() { 50 ready: function() {
54 // TODO(sjmiles): ensure read-only property is valued so the compound 51 // TODO(sjmiles): ensure read-only property is valued so the compound
55 // observer will fire 52 // observer will fire
56 if (this.focused === undefined) { 53 if (this.focused === undefined) {
57 this._setFocused(false); 54 this._setFocused(false);
58 } 55 }
56 this.addEventListener('focus', this._boundFocusBlurHandler, true);
57 this.addEventListener('blur', this._boundFocusBlurHandler, true);
59 }, 58 },
60 59
61 _focusHandler: function() { 60 _focusBlurHandler: function(event) {
62 this._setFocused(true); 61 var target = event.path ? event.path[0] : event.target;
63 }, 62 if (target === this) {
64 63 var focused = event.type === 'focus';
65 _blurHandler: function() { 64 this._setFocused(focused);
66 this._setFocused(false); 65 } else if (!this.shadowRoot) {
66 event.stopPropagation();
67 this.fire(event.type, {sourceEvent: event}, {
68 node: this,
69 bubbles: event.bubbles,
70 cancelable: event.cancelable
71 });
72 }
67 }, 73 },
68 74
69 _disabledChanged: function(disabled, old) { 75 _disabledChanged: function(disabled, old) {
70 this.setAttribute('aria-disabled', disabled ? 'true' : 'false'); 76 this.setAttribute('aria-disabled', disabled ? 'true' : 'false');
71 this.style.pointerEvents = disabled ? 'none' : ''; 77 this.style.pointerEvents = disabled ? 'none' : '';
72 if (disabled) { 78 if (disabled) {
73 this._oldTabIndex = this.tabIndex; 79 this._oldTabIndex = this.tabIndex;
74 this.focused = false; 80 this.focused = false;
75 this.tabIndex = -1; 81 this.tabIndex = -1;
76 } else if (this._oldTabIndex !== undefined) { 82 } else if (this._oldTabIndex !== undefined) {
77 this.tabIndex = this._oldTabIndex; 83 this.tabIndex = this._oldTabIndex;
78 } 84 }
79 }, 85 },
80 86
81 _changedControlState: function() { 87 _changedControlState: function() {
82 // _controlStateChanged is abstract, follow-on behaviors may implement it 88 // _controlStateChanged is abstract, follow-on behaviors may implement it
83 if (this._controlStateChanged) { 89 if (this._controlStateChanged) {
84 this._controlStateChanged(); 90 this._controlStateChanged();
85 } 91 }
86 } 92 }
87 93
88 }; 94 };
89 95
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698