Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Unified Diff: third_party/polymer/v1_0/components-chromium/iron-media-query/iron-media-query-extracted.js

Issue 1401633002: Update Polymer from 1.1.4 -> 1.1.5 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: dzhioev@ review Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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);
}
- });
-
+ });

Powered by Google App Engine
This is Rietveld 408576698