| Index: third_party/polymer/v1_0/components-chromium/iron-media-query/iron-media-query-extracted.js
|
| diff --git a/third_party/polymer/v1_0/components-chromium/iron-media-query/iron-media-query-extracted.js b/third_party/polymer/v1_0/components-chromium/iron-media-query/iron-media-query-extracted.js
|
| index a827c28bd1705f6bfbb8940fdb646e688d4f5fc3..029d3babad82bc266f7f3bb9ecb38c28dcbe9240 100644
|
| --- a/third_party/polymer/v1_0/components-chromium/iron-media-query/iron-media-query-extracted.js
|
| +++ b/third_party/polymer/v1_0/components-chromium/iron-media-query/iron-media-query-extracted.js
|
| @@ -1,6 +1,4 @@
|
| -
|
| -
|
| - Polymer({
|
| +Polymer({
|
|
|
| is: 'iron-media-query',
|
|
|
| @@ -22,23 +20,47 @@
|
| query: {
|
| type: String,
|
| observer: 'queryChanged'
|
| + },
|
| +
|
| + _boundMQHandler: {
|
| + value: function() {
|
| + return this.queryHandler.bind(this);
|
| + }
|
| }
|
| + },
|
|
|
| + attached: function() {
|
| + this.queryChanged();
|
| },
|
|
|
| - created: function() {
|
| - this._mqHandler = this.queryHandler.bind(this);
|
| + detached: function() {
|
| + this._remove();
|
| },
|
|
|
| - queryChanged: function(query) {
|
| + _add: function() {
|
| if (this._mq) {
|
| - this._mq.removeListener(this._mqHandler);
|
| + this._mq.addListener(this._boundMQHandler);
|
| + }
|
| + },
|
| +
|
| + _remove: function() {
|
| + if (this._mq) {
|
| + this._mq.removeListener(this._boundMQHandler);
|
| + }
|
| + this._mq = null;
|
| + },
|
| +
|
| + queryChanged: function() {
|
| + this._remove();
|
| + var query = this.query;
|
| + if (!query) {
|
| + return;
|
| }
|
| if (query[0] !== '(') {
|
| query = '(' + query + ')';
|
| }
|
| this._mq = window.matchMedia(query);
|
| - this._mq.addListener(this._mqHandler);
|
| + this._add();
|
| this.queryHandler(this._mq);
|
| },
|
|
|
| @@ -46,5 +68,4 @@
|
| this._setQueryMatches(mq.matches);
|
| }
|
|
|
| - });
|
| -
|
| + });
|
|
|