Commit 4b22c8ba authored by JC Brand's avatar JC Brand

Use sizzle for tricky selector queries

Specifically involving querying by the 'xmlns' attribute, where I've had issues
in the past.
parent 77f93a64
...@@ -27,6 +27,7 @@ require.config({ ...@@ -27,6 +27,7 @@ require.config({
"moment": "node_modules/moment/moment", "moment": "node_modules/moment/moment",
"pluggable": "node_modules/pluggable.js/pluggable", "pluggable": "node_modules/pluggable.js/pluggable",
"polyfill": "src/polyfill", "polyfill": "src/polyfill",
"sizzle": "node_modules/jquery/sizzle/dist/sizzle",
"strophe": "node_modules/strophe.js/src/wrapper", "strophe": "node_modules/strophe.js/src/wrapper",
"strophe-base64": "node_modules/strophe.js/src/base64", "strophe-base64": "node_modules/strophe.js/src/base64",
"strophe-bosh": "node_modules/strophe.js/src/bosh", "strophe-bosh": "node_modules/strophe.js/src/bosh",
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
(function (root, factory) { (function (root, factory) {
define("converse-core", [ define("converse-core", [
"sizzle",
"jquery", "jquery",
"lodash", "lodash",
"polyfill", "polyfill",
...@@ -19,7 +20,7 @@ ...@@ -19,7 +20,7 @@
"backbone.browserStorage", "backbone.browserStorage",
"backbone.overview", "backbone.overview",
], factory); ], factory);
}(this, function ($, _, dummy, utils, moment, Strophe, pluggable) { }(this, function (sizzle, $, _, dummy, utils, moment, Strophe, pluggable) {
/* /*
* Cannot use this due to Safari bug. * Cannot use this due to Safari bug.
* See https://github.com/jcbrand/converse.js/issues/196 * See https://github.com/jcbrand/converse.js/issues/196
...@@ -1094,7 +1095,7 @@ ...@@ -1094,7 +1095,7 @@
} }
converse.connection.send($iq({type: 'result', id: id, from: converse.connection.jid})); converse.connection.send($iq({type: 'result', id: id, from: converse.connection.jid}));
var items = iq.querySelectorAll('query[xmlns="'+Strophe.NS.ROSTER+'"] item'); var items = sizzle('query[xmlns="'+Strophe.NS.ROSTER+'"] item', iq);
_.each(items, this.updateContact.bind(this)); _.each(items, this.updateContact.bind(this));
converse.emit('rosterPush', iq); converse.emit('rosterPush', iq);
return true; return true;
...@@ -1114,7 +1115,7 @@ ...@@ -1114,7 +1115,7 @@
/* An IQ stanza containing the roster has been received from /* An IQ stanza containing the roster has been received from
* the XMPP server. * the XMPP server.
*/ */
var items = iq.querySelectorAll('query[xmlns="'+Strophe.NS.ROSTER+'"] item'); var items = sizzle('query[xmlns="'+Strophe.NS.ROSTER+'"] item', iq);
_.each(items, this.updateContact.bind(this)); _.each(items, this.updateContact.bind(this));
converse.emit('roster', iq); converse.emit('roster', iq);
}, },
...@@ -1228,7 +1229,7 @@ ...@@ -1228,7 +1229,7 @@
} }
} }
return; return;
} else if (presence.querySelectorAll('x[xmlns="'+Strophe.NS.MUC+'"]').length) { } else if (sizzle('query[xmlns="'+Strophe.NS.MUC+'"]', presence).length) {
return; // Ignore MUC return; // Ignore MUC
} }
if (contact && (status_message !== contact.get('status'))) { if (contact && (status_message !== contact.get('status'))) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment