|
19 | 19 |
|
20 | 20 | Polymer.register(this, { |
21 | 21 | vertical: false, |
22 | | - ready: function() { |
| 22 | + inserted: function() { |
23 | 23 | Polymer.installControllerStyles(this, element); |
24 | | - }, |
25 | | - insertedCallback: function() { |
26 | 24 | this.layoutContainer = this.parentNode.host || this.parentNode; |
27 | 25 | this.layoutContainer.classList.add('flexbox'); |
28 | 26 | this.verticalChanged(); |
29 | 27 | this.alignChanged(); |
30 | 28 | this.justifyChanged(); |
31 | 29 | }, |
32 | | - toggleContainerClass: function(name, add) { |
| 30 | + switchContainerClass: function(prefix, old, name) { |
33 | 31 | if (this.layoutContainer && name) { |
34 | | - this.layoutContainer.classList.toggle(name, add); |
| 32 | + this.layoutContainer.classList.switch( |
| 33 | + prefix + old, prefix + name); |
35 | 34 | } |
36 | 35 | }, |
37 | 36 | verticalChanged: function() { |
38 | | - this.toggleContainerClass('column', this.vertical); |
| 37 | + if (this.layoutContainer) { |
| 38 | + this.layoutContainer.classList.toggle('column', this.vertical); |
| 39 | + } |
39 | 40 | }, |
40 | 41 | alignChanged: function(old) { |
41 | | - this.toggleContainerClass(old && 'align-' + old, false); |
42 | | - this.toggleContainerClass(this.align && 'align-' + this.align, true); |
| 42 | + this.switchContainerClass('align-', old, this.align); |
43 | 43 | }, |
44 | 44 | justifyChanged: function(old) { |
45 | | - this.toggleContainerClass(old && 'justify-' + old, false); |
46 | | - this.toggleContainerClass(this.justify && 'justify-' + this.justify, true); |
| 45 | + this.switchContainerClass('justify-', old, this.justify); |
47 | 46 | } |
48 | 47 | }); |
49 | 48 | </script> |
|
0 commit comments