add polyfills for .matches and .closest

This commit is contained in:
igoradamenko
2018-01-23 09:50:31 +02:00
parent aef02690af
commit 8cd75f7b1e
2 changed files with 19 additions and 1 deletions
+5 -1
View File
@@ -1,4 +1,8 @@
import 'babel-polyfill'; // TODO: remove it
import 'mimic'; // TODO: it's for dev only
import './polyfills'; // TODO: check it
import fetcher from './fetcher';
import render from './render';
@@ -7,5 +11,5 @@ require('./main.scss');
// TODO: add preloader
// TODO: all of these settings must be optional params
fetcher
.get('/find?site=remark&url=https://radio-t.com/p/2017/12/16/podcast-576/&sort=time&format=tree')
.get('/find?url=https://radio-t.com/p/2017/12/16/podcast-576/&sort=time&format=tree')
.then(render);
+14
View File
@@ -0,0 +1,14 @@
if (!Element.prototype.matches)
Element.prototype.matches = Element.prototype.msMatchesSelector ||
Element.prototype.webkitMatchesSelector;
if (!Element.prototype.closest)
Element.prototype.closest = function(s) {
var el = this;
if (!document.documentElement.contains(el)) return null;
do {
if (el.matches(s)) return el;
el = el.parentElement || el.parentNode;
} while (el !== null);
return null;
};