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

Side by Side Diff: third_party/polymer/v1_0/components/iron-behaviors/iron-control-state.html

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 @license 2 @license
3 Copyright (c) 2015 The Polymer Project Authors. All rights reserved. 3 Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
4 This code may only be used under the BSD style license found at http://polymer.g ithub.io/LICENSE.txt 4 This code may only be used under the BSD style license found at http://polymer.g ithub.io/LICENSE.txt
5 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt 5 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
6 The complete set of contributors may be found at http://polymer.github.io/CONTRI BUTORS.txt 6 The complete set of contributors may be found at http://polymer.github.io/CONTRI BUTORS.txt
7 Code distributed by Google as part of the polymer project is also 7 Code distributed by Google as part of the polymer project is also
8 subject to an additional IP rights grant found at http://polymer.github.io/PATEN TS.txt 8 subject to an additional IP rights grant found at http://polymer.github.io/PATEN TS.txt
9 --> 9 -->
10 10
11 <link rel="import" href="../polymer/polymer.html"> 11 <link rel="import" href="../polymer/polymer.html">
12 12
13 <script> 13 <script>
14 14
15 /** @polymerBehavior */ 15 /**
16 16 * @demo demo/index.html
17 * @polymerBehavior
18 */
17 Polymer.IronControlState = { 19 Polymer.IronControlState = {
18 20
19 properties: { 21 properties: {
20 22
21 /** 23 /**
22 * If true, the element currently has focus. 24 * If true, the element currently has focus.
23 *
24 * @attribute focused
25 * @type boolean
26 * @default false
27 */ 25 */
28 focused: { 26 focused: {
29 type: Boolean, 27 type: Boolean,
30 value: false, 28 value: false,
31 notify: true, 29 notify: true,
32 readOnly: true, 30 readOnly: true,
33 reflectToAttribute: true 31 reflectToAttribute: true
34 }, 32 },
35 33
36 /** 34 /**
37 * If true, the user cannot interact with this element. 35 * If true, the user cannot interact with this element.
38 *
39 * @attribute disabled
40 * @type boolean
41 * @default false
42 */ 36 */
43 disabled: { 37 disabled: {
44 type: Boolean, 38 type: Boolean,
45 value: false, 39 value: false,
46 notify: true, 40 notify: true,
47 observer: '_disabledChanged', 41 observer: '_disabledChanged',
48 reflectToAttribute: true 42 reflectToAttribute: true
49 }, 43 },
50 44
51 _oldTabIndex: { 45 _oldTabIndex: {
52 type: Number 46 type: Number
47 },
48
49 _boundFocusBlurHandler: {
50 type: Function,
51 value: function() {
52 return this._focusBlurHandler.bind(this);
53 }
53 } 54 }
55
54 }, 56 },
55 57
56 observers: [ 58 observers: [
57 '_changedControlState(focused, disabled)' 59 '_changedControlState(focused, disabled)'
58 ], 60 ],
59 61
60 listeners: {
61 focus: '_focusHandler',
62 blur: '_blurHandler'
63 },
64
65 ready: function() { 62 ready: function() {
66 // TODO(sjmiles): ensure read-only property is valued so the compound 63 // TODO(sjmiles): ensure read-only property is valued so the compound
67 // observer will fire 64 // observer will fire
68 if (this.focused === undefined) { 65 if (this.focused === undefined) {
69 this._setFocused(false); 66 this._setFocused(false);
70 } 67 }
68 this.addEventListener('focus', this._boundFocusBlurHandler, true);
69 this.addEventListener('blur', this._boundFocusBlurHandler, true);
71 }, 70 },
72 71
73 _focusHandler: function() { 72 _focusBlurHandler: function(event) {
74 this._setFocused(true); 73 var target = event.path ? event.path[0] : event.target;
75 }, 74 if (target === this) {
76 75 var focused = event.type === 'focus';
77 _blurHandler: function() { 76 this._setFocused(focused);
78 this._setFocused(false); 77 } else if (!this.shadowRoot) {
78 event.stopPropagation();
79 this.fire(event.type, {sourceEvent: event}, {
80 node: this,
81 bubbles: event.bubbles,
82 cancelable: event.cancelable
83 });
84 }
79 }, 85 },
80 86
81 _disabledChanged: function(disabled, old) { 87 _disabledChanged: function(disabled, old) {
82 this.setAttribute('aria-disabled', disabled ? 'true' : 'false'); 88 this.setAttribute('aria-disabled', disabled ? 'true' : 'false');
83 this.style.pointerEvents = disabled ? 'none' : ''; 89 this.style.pointerEvents = disabled ? 'none' : '';
84 if (disabled) { 90 if (disabled) {
85 this._oldTabIndex = this.tabIndex; 91 this._oldTabIndex = this.tabIndex;
86 this.focused = false; 92 this.focused = false;
87 this.tabIndex = -1; 93 this.tabIndex = -1;
88 } else if (this._oldTabIndex !== undefined) { 94 } else if (this._oldTabIndex !== undefined) {
89 this.tabIndex = this._oldTabIndex; 95 this.tabIndex = this._oldTabIndex;
90 } 96 }
91 }, 97 },
92 98
93 _changedControlState: function() { 99 _changedControlState: function() {
94 // _controlStateChanged is abstract, follow-on behaviors may implement it 100 // _controlStateChanged is abstract, follow-on behaviors may implement it
95 if (this._controlStateChanged) { 101 if (this._controlStateChanged) {
96 this._controlStateChanged(); 102 this._controlStateChanged();
97 } 103 }
98 } 104 }
99 105
100 }; 106 };
101 107
102 </script> 108 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698