Skip to content
This repository has been archived by the owner on Dec 19, 2024. It is now read-only.

Commit

Permalink
revert setting of sizingTarget, should be done in attached
Browse files Browse the repository at this point in the history
  • Loading branch information
valdrinkoshi committed Dec 9, 2016
1 parent 1e8d930 commit 092aaf4
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions iron-dropdown.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
<dom-module id="iron-dropdown">
<template>
<style>
:host {
position: fixed;
}

#contentWrapper ::slotted(*) {
overflow: auto;
Expand All @@ -55,7 +58,7 @@
</style>

<div id="contentWrapper">
<slot></slot>
<slot id="content"></slot>
</div>
</template>

Expand Down Expand Up @@ -144,17 +147,6 @@
value: false
},

/**
* The element that will receive a `max-height`/`width`. Overriden
* default value from `IronFitBehavior` to be the `containedElement` if
* not defined.
* @type {!Element}
*/
sizingTarget: {
type: Object,
value: null
},

/**
* Callback for scroll events.
* @type {Function}
Expand All @@ -180,7 +172,7 @@
* The element that is contained by the dropdown, if any.
*/
get containedElement() {
var nodes = Polymer.dom(this.$.contentWrapper).getEffectiveChildNodes();
var nodes = Polymer.dom(this.$.content).getDistributedNodes();
var i = 0;
while (nodes[i] && nodes[i].nodeType !== Node.ELEMENT_NODE) {
i++;
Expand All @@ -196,6 +188,15 @@
this._refitOnScrollRAF = null;
},

attached: function() {
if (!this.sizingTarget || this.sizingTarget === this) {
// Need to flush to force distribution in order to get the containedElement
//TODO(valdrin) remove flush when webcomponents/shadydom#56 is solved.
window.ShadyDOM && window.ShadyDOM.flush();
this.sizingTarget = this.containedElement;
}
},

detached: function() {
this.cancelAnimation();
document.removeEventListener('scroll', this._boundOnCaptureScroll);
Expand All @@ -210,7 +211,6 @@
if (this.opened && this.disabled) {
this.cancel();
} else {
this.sizingTarget = this.sizingTarget || this.containedElement;
this.cancelAnimation();
this._updateAnimationConfig();
this._saveScrollPosition();
Expand Down

0 comments on commit 092aaf4

Please sign in to comment.