Skip to content

Commit

Permalink
Fix failed tests without jQuery on IE9-11 (#668)
Browse files Browse the repository at this point in the history
  • Loading branch information
ovchinnikov authored Jul 7, 2017
1 parent f07b8d1 commit f6ad138
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
21 changes: 21 additions & 0 deletions js/core/polyfills/matches.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"use strict";

var matches = Element.prototype.matches ||
Element.prototype.matchesSelector ||
Element.prototype.mozMatchesSelector ||
Element.prototype.msMatchesSelector ||
Element.prototype.oMatchesSelector ||
Element.prototype.webkitMatchesSelector ||
function(selector) {
var items = (this.document || this.ownerDocument).querySelectorAll(selector);

for(var i = 0; i < items.length; i++) {
if(items === this) {
return true;
}
}
};

module.exports = function(element, selector) {
return matches.call(element, selector);
};
5 changes: 3 additions & 2 deletions js/core/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
var $ = require("jquery");
var rendererStrategy = require("./native_renderer_strategy");
var typeUtils = require("./utils/type");
var matches = require("./polyfills/matches");

var useJQueryRenderer = window.useJQueryRenderer !== false;

Expand Down Expand Up @@ -380,8 +381,8 @@ if(!useJQueryRenderer) {
var result = [];
for(var i = 0; i < this.length; i++) {
var item = this[i];
if(item.nodeType === Node.ELEMENT_NODE && typeUtils.isString(selector)) {
item.matches(selector) && result.push(item);
if(item.nodeType === Node.ELEMENT_NODE && typeUtils.type(selector) === "string") {
matches(item, selector) && result.push(item);
} else if(selector.nodeType || typeUtils.isWindow(selector)) {
selector === item && result.push(item);
} else if(typeUtils.isFunction(selector)) {
Expand Down

0 comments on commit f6ad138

Please sign in to comment.