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

Side by Side Diff: third_party/polymer/components-chromium/core-label/core-label-extracted.js

Issue 1215543002: Remove Polymer 0.5. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix unit test Created 5 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 unified diff | Download patch
OLDNEW
(Empty)
1
2 (function() {
3
4 var ID = 0;
5 function generate(node) {
6 if (!node.id) {
7 node.id = 'core-label-' + ID++;
8 }
9 return node.id;
10 }
11
12 Polymer('core-label', {
13 /**
14 * A query selector string for a "target" element not nested in the `<co re-label>`
15 *
16 * @attribute for
17 * @type string
18 * @default ''
19 */
20 publish: {
21 'for': {reflect: true, value: ''}
22 },
23 eventDelegates: {
24 'tap': 'tapHandler'
25 },
26 created: function() {
27 generate(this);
28 this._forElement = null;
29 },
30 ready: function() {
31 if (!this.for) {
32 this._forElement = this.querySelector('[for]');
33 this._tie();
34 }
35 },
36 tapHandler: function(ev) {
37 if (!this._forElement) {
38 return;
39 }
40 if (ev.target === this._forElement) {
41 return;
42 }
43 this._forElement.focus();
44 this._forElement.click();
45 this.fire('tap', null, this._forElement);
46 },
47 _tie: function() {
48 if (this._forElement) {
49 this._forElement.setAttribute('aria-labelledby', this.id);
50 }
51 },
52 _findScope: function() {
53 var n = this.parentNode;
54 while(n && n.parentNode) {
55 n = n.parentNode;
56 }
57 return n;
58 },
59 forChanged: function(oldFor, newFor) {
60 if (this._forElement) {
61 this._forElement.removeAttribute('aria-labelledby');
62 }
63 var scope = this._findScope();
64 if (!scope) {
65 return;
66 }
67 this._forElement = scope.querySelector(newFor);
68 if (this._forElement) {
69 this._tie();
70 }
71 }
72 });
73 })();
74
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698