123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- function Support(document) {
- this.rangeBounds = this.testRangeBounds(document);
- this.cors = this.testCORS();
- this.svg = this.testSVG();
- }
- Support.prototype.testRangeBounds = function(document) {
- var range, testElement, rangeBounds, rangeHeight, support = false;
- if (document.createRange) {
- range = document.createRange();
- if (range.getBoundingClientRect) {
- testElement = document.createElement('boundtest');
- testElement.style.height = "123px";
- testElement.style.display = "block";
- document.body.appendChild(testElement);
- range.selectNode(testElement);
- rangeBounds = range.getBoundingClientRect();
- rangeHeight = rangeBounds.height;
- if (rangeHeight === 123) {
- support = true;
- }
- document.body.removeChild(testElement);
- }
- }
- return support;
- };
- Support.prototype.testCORS = function() {
- return typeof((new Image()).crossOrigin) !== "undefined";
- };
- Support.prototype.testSVG = function() {
- var img = new Image();
- var canvas = document.createElement("canvas");
- var ctx = canvas.getContext("2d");
- img.src = "data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg'></svg>";
- try {
- ctx.drawImage(img, 0, 0);
- canvas.toDataURL();
- } catch(e) {
- return false;
- }
- return true;
- };
- module.exports = Support;
|