Chromium Code Reviews| Index: third_party/polymer/v1_0/components-chromium/iron-collapse/iron-collapse-extracted.js |
| diff --git a/third_party/polymer/v1_0/components-chromium/iron-collapse/iron-collapse-extracted.js b/third_party/polymer/v1_0/components-chromium/iron-collapse/iron-collapse-extracted.js |
| index 9e5f2aa6f5b7772555c95321167e71254f7b8cdb..394a0184993009957f46f2ec14db2e147ef280e4 100644 |
| --- a/third_party/polymer/v1_0/components-chromium/iron-collapse/iron-collapse-extracted.js |
| +++ b/third_party/polymer/v1_0/components-chromium/iron-collapse/iron-collapse-extracted.js |
| @@ -46,6 +46,22 @@ Polymer({ |
| return this.horizontal ? 'width' : 'height'; |
| }, |
| + /** |
| + * `maxWidth` or `maxHeight`. |
| + * @private |
| + */ |
| + get _dimensionMax() { |
| + return this.horizontal ? 'maxWidth' : 'maxHeight'; |
| + }, |
| + |
| + /** |
| + * `max-width` or `max-height`. |
| + * @private |
| + */ |
| + get _dimensionMaxCss() { |
| + return this.horizontal ? 'max-width' : 'max-height'; |
| + }, |
| + |
| hostAttributes: { |
| role: 'group', |
| 'aria-hidden': 'true', |
| @@ -78,9 +94,15 @@ Polymer({ |
| this.opened = false; |
| }, |
| + /** |
| + * Updates the size of the element. |
| + * @param {string} size The new value for `maxWidth`/`maxHeight` as css property value, usually `auto` or `0px`. |
|
Dan Beam
2016/06/16 23:01:54
this was !String, which was a compiler error
i se
michaelpg
2016/06/16 23:03:25
add this to chromium.patch
Dan Beam
2016/06/17 00:42:10
Done.
|
| + * @param {boolean=} animated if `true` updates the size with an animation, otherwise without. |
| + */ |
| updateSize: function(size, animated) { |
| // No change! |
| - if (this.style[this.dimension] === size) { |
| + var curSize = this.style[this._dimensionMax]; |
| + if (curSize === size || (size === 'auto' && !curSize)) { |
| return; |
| } |
| @@ -92,11 +114,11 @@ Polymer({ |
| // For `auto` we must calculate what is the final size for the animation. |
| // After the transition is done, _transitionEnd will set the size back to `auto`. |
| if (size === 'auto') { |
| - this.style[this.dimension] = size; |
| + this.style[this._dimensionMax] = ''; |
| size = this._calcSize(); |
| } |
| // Go to startSize without animation. |
| - this.style[this.dimension] = startSize; |
| + this.style[this._dimensionMax] = startSize; |
| // Force layout to ensure transition will go. Set offsetHeight to itself |
| // so that compilers won't remove it. |
| this.offsetHeight = this.offsetHeight; |
| @@ -104,7 +126,11 @@ Polymer({ |
| this._updateTransition(true); |
| } |
| // Set the final size. |
| - this.style[this.dimension] = size; |
| + if (size === 'auto') { |
| + this.style[this._dimensionMax] = ''; |
| + } else { |
| + this.style[this._dimensionMax] = size; |
| + } |
| }, |
| /** |
| @@ -115,7 +141,7 @@ Polymer({ |
| * @deprecated since version 1.0.4 |
| */ |
| enableTransition: function(enabled) { |
| - console.warn('`enableTransition()` is deprecated, use `noAnimation` instead.'); |
| + Polymer.Base._warn('`enableTransition()` is deprecated, use `noAnimation` instead.'); |
| this.noAnimation = !enabled; |
| }, |
| @@ -124,8 +150,8 @@ Polymer({ |
| }, |
| _horizontalChanged: function() { |
| - this.style.transitionProperty = this.dimension; |
| - var otherDimension = this.dimension === 'width' ? 'height' : 'width'; |
| + this.style.transitionProperty = this._dimensionMaxCss; |
| + var otherDimension = this._dimensionMax === 'maxWidth' ? 'maxHeight' : 'maxWidth'; |
| this.style[otherDimension] = ''; |
| this.updateSize(this.opened ? 'auto' : '0px', false); |
| }, |
| @@ -149,7 +175,7 @@ Polymer({ |
| _transitionEnd: function() { |
| if (this.opened) { |
| - this.style[this.dimension] = 'auto'; |
| + this.style[this._dimensionMax] = ''; |
| } |
| this.toggleClass('iron-collapse-closed', !this.opened); |
| this.toggleClass('iron-collapse-opened', this.opened); |
| @@ -174,4 +200,4 @@ Polymer({ |
| return this.getBoundingClientRect()[this.dimension] + 'px'; |
| } |
| - }); |
| + }); |