update components

This commit is contained in:
Luke Pulverenti 2016-03-22 23:04:42 -04:00
parent 5f5a748b37
commit 18c23db5c9
7 changed files with 150 additions and 27 deletions

View file

@ -32,14 +32,14 @@
"web-component-tester": "^4.0.0",
"webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0"
},
"homepage": "https://github.com/PolymerElements/iron-icon",
"homepage": "https://github.com/polymerelements/iron-icon",
"_release": "1.0.8",
"_resolution": {
"type": "version",
"tag": "v1.0.8",
"commit": "f36b38928849ef3853db727faa8c9ef104d611eb"
},
"_source": "git://github.com/PolymerElements/iron-icon.git",
"_source": "git://github.com/polymerelements/iron-icon.git",
"_target": "^1.0.0",
"_originalSource": "PolymerElements/iron-icon"
"_originalSource": "polymerelements/iron-icon"
}

View file

@ -1,6 +1,6 @@
{
"name": "iron-overlay-behavior",
"version": "1.5.1",
"version": "1.5.2",
"license": "http://polymer.github.io/LICENSE.txt",
"description": "Provides a behavior for making an element an overlay",
"private": true,
@ -35,11 +35,11 @@
},
"ignore": [],
"homepage": "https://github.com/polymerelements/iron-overlay-behavior",
"_release": "1.5.1",
"_release": "1.5.2",
"_resolution": {
"type": "version",
"tag": "v1.5.1",
"commit": "b6f4126ecbfdc9dc149beac8e7fbe201bbd14ad5"
"tag": "v1.5.2",
"commit": "740705930a3d30c8381e75f379aeea5eae89847b"
},
"_source": "git://github.com/polymerelements/iron-overlay-behavior.git",
"_target": "^1.0.0",

View file

@ -0,0 +1,33 @@
<!-- Instructions: https://github.com/PolymerElements/iron-overlay-behavior/CONTRIBUTING.md#filing-issues -->
### Description
<!-- Example: The `paper-foo` element causes the page to turn pink when clicked. -->
### Expected outcome
<!-- Example: The page stays the same color. -->
### Actual outcome
<!-- Example: The page turns pink. -->
### Live Demo
<!-- Example: https://jsbin.com/cagaye/edit?html,output -->
### Steps to reproduce
<!-- Example
1. Put a `paper-foo` element in the page.
2. Open the page in a web browser.
3. Click the `paper-foo` element.
-->
### Browsers Affected
<!-- Check all that apply -->
- [ ] Chrome
- [ ] Firefox
- [ ] Safari 9
- [ ] Safari 8
- [ ] Safari 7
- [ ] Edge
- [ ] IE 11
- [ ] IE 10

View file

@ -1,6 +1,6 @@
{
"name": "iron-overlay-behavior",
"version": "1.5.1",
"version": "1.5.2",
"license": "http://polymer.github.io/LICENSE.txt",
"description": "Provides a behavior for making an element an overlay",
"private": true,

View file

@ -306,16 +306,13 @@ context. You should place this element as a child of `<body>` whenever possible.
return;
}
this._manager.addOrRemoveOverlay(this);
this.__isAnimating = true;
if (this.opened) {
this._prepareRenderOpened();
} else {
this._manager.removeOverlay(this);
}
this._manager.trackBackdrop(this);
if (this._openChangedAsync) {
this.cancelAsync(this._openChangedAsync);
}
@ -350,7 +347,7 @@ context. You should place this element as a child of `<body>` whenever possible.
this.__shouldRemoveTabIndex = false;
}
if (this.opened) {
this._manager.trackBackdrop(this);
this._manager.trackBackdrop();
if (this.withBackdrop) {
this.backdropElement.prepare();
// Give time to be added to document.
@ -369,8 +366,6 @@ context. You should place this element as a child of `<body>` whenever possible.
*/
_prepareRenderOpened: function() {
this._manager.addOverlay(this);
// Needed to calculate the size of the overlay so that transitions on its size
// will have the correct starting points.
this._preparePositioning();

View file

@ -77,11 +77,56 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
return active;
},
/**
* Brings the overlay at the specified index to the front.
* @param {number} i
* @private
*/
_bringOverlayAtIndexToFront: function(i) {
var overlay = this._overlays[i];
var lastI = this._overlays.length - 1;
// If already the top element, return.
if (!overlay || i === lastI) {
return;
}
// Update z-index to be on top.
var minimumZ = Math.max(this.currentOverlayZ(), this._minimumZ);
if (this._getZ(overlay) <= minimumZ) {
this._applyOverlayZ(overlay, minimumZ);
}
// Shift other overlays behind the new on top.
while (i < lastI) {
this._overlays[i] = this._overlays[i + 1];
i++;
}
this._overlays[lastI] = overlay;
},
/**
* Adds the overlay and updates its z-index if it's opened, or removes it if it's closed.
* Also updates the backdrop z-index.
* @param {Element} overlay
*/
addOrRemoveOverlay: function(overlay) {
if (overlay.opened) {
this.addOverlay(overlay);
} else {
this.removeOverlay(overlay);
}
this.trackBackdrop();
},
/**
* Tracks overlays for z-index and focus management.
* @param {Element} overlay
*/
addOverlay: function(overlay) {
var i = this._overlays.indexOf(overlay);
if (i >= 0) {
this._bringOverlayAtIndexToFront(i);
return;
}
var minimumZ = Math.max(this.currentOverlayZ(), this._minimumZ);
this._overlays.push(overlay);
var newZ = this.currentOverlayZ();
@ -97,16 +142,17 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
*/
removeOverlay: function(overlay) {
var i = this._overlays.indexOf(overlay);
if (i >= 0) {
this._overlays.splice(i, 1);
this._setZ(overlay, '');
if (i === -1) {
return;
}
this._overlays.splice(i, 1);
this._setZ(overlay, '');
var node = overlay.restoreFocusOnClose ? overlay.restoreFocusNode : null;
overlay.restoreFocusNode = null;
// Focus back only if still contained in document.body
if (node && Polymer.dom(document.body).deepContains(node)) {
node.focus();
}
var node = overlay.restoreFocusOnClose ? overlay.restoreFocusNode : null;
overlay.restoreFocusNode = null;
// Focus back only if still contained in document.body
if (node && Polymer.dom(document.body).deepContains(node)) {
node.focus();
}
},
@ -152,9 +198,9 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
},
/**
* @param {Element} overlay The overlay that updated its withBackdrop.
* Updates the backdrop z-index.
*/
trackBackdrop: function(overlay) {
trackBackdrop: function() {
this.backdropElement.style.zIndex = this.backdropZ();
},

View file

@ -751,6 +751,55 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
done();
})
});
});
suite('Manager overlays in sync', function() {
var overlay1, overlay2;
var overlays;
setup(function() {
var f = fixture('multiple');
overlay1 = f[0];
overlay2 = f[1];
overlays = Polymer.IronOverlayManager._overlays;
});
test('no duplicates after attached', function(done) {
overlay1 = document.createElement('test-overlay');
overlay1.addEventListener('iron-overlay-opened',function() {
assert.equal(overlays.length, 1, 'correct count after open and attached');
document.body.removeChild(overlay1);
done();
});
overlay1.opened = true;
assert.equal(overlays.length, 1, 'immediately updated');
document.body.appendChild(overlay1);
});
test('open twice handled', function() {
overlay1.open();
assert.equal(overlays.length, 1, '1 overlay after open');
overlay1.open();
assert.equal(overlays.length, 1, '1 overlay after second open');
});
test('close handled', function() {
overlay1.open();
overlay1.close();
assert.equal(overlays.length, 0, '0 overlays after close');
});
test('open/close brings overlay on top', function() {
overlay1.open();
overlay2.open();
assert.equal(overlays.indexOf(overlay1), 0, 'overlay1 at index 0');
assert.equal(overlays.indexOf(overlay2), 1, 'overlay2 at index 1');
overlay1.close();
overlay1.open();
assert.equal(overlays.indexOf(overlay1), 1, 'overlay1 moved at index 1');
assert.isAbove(parseInt(overlay1.style.zIndex), parseInt(overlay2.style.zIndex), 'overlay1 on top of overlay2');
});
});
suite('z-ordering', function() {