chore(polyfill): break DOM polyfills into external file

This commit is contained in:
Adam Bradley
2016-09-19 08:56:25 -05:00
parent 0e8ebe5734
commit 9fca394bdb
4 changed files with 31 additions and 32 deletions

View File

@ -95,11 +95,6 @@ task('polyfill.modern', (done) => {
});
task('polyfill.copy-readme', (done) => {
const rename = require('gulp-rename');
return src('scripts/npm/polyfills.readme.md')
.pipe(rename({
basename: 'README'
}))
return src('scripts/polyfill/readme.md')
.pipe(dest('dist/ionic-angular/polyfills/'), done);
});

View File

@ -0,0 +1,30 @@
(function(){
"use strict";
if (typeof Element.prototype.matches !== 'function') {
Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector || function matches(selector) {
var element = this;
var elements = (element.document || element.ownerDocument).querySelectorAll(selector);
var index = 0;
while (elements[index] && elements[index] !== element) {
++index;
}
return Boolean(elements[index]);
};
}
if (typeof Element.prototype.closest !== 'function') {
Element.prototype.closest = function closest(selector) {
var element = this;
while (element && element.nodeType === 1) {
if (element.matches(selector)) {
return element;
}
element = element.parentNode;
}
return null;
};
}
})();

View File

@ -247,32 +247,6 @@ export function copyInputAttributes(srcElement: HTMLElement, destElement: HTMLEl
}
}
// TODO: Add to external polyfill script
if (typeof Element.prototype.matches !== 'function') {
Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector || function matches(selector) {
var element = this;
var elements = (element.document || element.ownerDocument).querySelectorAll(selector);
var index = 0;
while (elements[index] && elements[index] !== element) {
++index;
}
return Boolean(elements[index]);
};
}
if (typeof Element.prototype.closest !== 'function') {
Element.prototype.closest = function closest(selector) {
var element = this;
while (element && element.nodeType === 1) {
if (element.matches(selector)) {
return element;
}
element = element.parentNode;
}
return null;
};
}
/**
* Get the element offsetWidth and offsetHeight. Values are cached