remove useless feature with new browsers
This commit is contained in:
@@ -10,36 +10,16 @@ import 'pathseg';
|
|||||||
|
|
||||||
import { NS } from './namespaces.js';
|
import { NS } from './namespaces.js';
|
||||||
|
|
||||||
const supportsSVG_ = (function () {
|
|
||||||
return Boolean(document.createElementNS && document.createElementNS(NS.SVG, 'svg').createSVGRect);
|
|
||||||
}());
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @function module:browser.supportsSvg
|
|
||||||
* @returns {boolean}
|
|
||||||
*/
|
|
||||||
export const supportsSvg = () => supportsSVG_;
|
|
||||||
|
|
||||||
const { userAgent } = navigator;
|
const { userAgent } = navigator;
|
||||||
const svg = document.createElementNS(NS.SVG, 'svg');
|
const svg = document.createElementNS(NS.SVG, 'svg');
|
||||||
|
|
||||||
// Note: Browser sniffing should only be used if no other detection method is possible
|
// Note: Browser sniffing should only be used if no other detection method is possible
|
||||||
const isOpera_ = Boolean(window.opera);
|
|
||||||
const isWebkit_ = userAgent.includes('AppleWebKit');
|
const isWebkit_ = userAgent.includes('AppleWebKit');
|
||||||
const isGecko_ = userAgent.includes('Gecko/');
|
const isGecko_ = userAgent.includes('Gecko/');
|
||||||
const isChrome_ = userAgent.includes('Chrome/');
|
const isChrome_ = userAgent.includes('Chrome/');
|
||||||
const isWindows_ = userAgent.includes('Windows');
|
|
||||||
const isMac_ = userAgent.includes('Macintosh');
|
const isMac_ = userAgent.includes('Macintosh');
|
||||||
const isTouch_ = 'ontouchstart' in window;
|
const isTouch_ = 'ontouchstart' in window;
|
||||||
|
|
||||||
const supportsSelectors_ = (function () {
|
|
||||||
return Boolean(svg.querySelector);
|
|
||||||
}());
|
|
||||||
|
|
||||||
const supportsXpath_ = (function () {
|
|
||||||
return Boolean(document.evaluate);
|
|
||||||
}());
|
|
||||||
|
|
||||||
// segList functions (for FF1.5 and 2.0)
|
// segList functions (for FF1.5 and 2.0)
|
||||||
const supportsPathReplaceItem_ = (function () {
|
const supportsPathReplaceItem_ = (function () {
|
||||||
const path = document.createElementNS(NS.SVG, 'path');
|
const path = document.createElementNS(NS.SVG, 'path');
|
||||||
@@ -113,11 +93,6 @@ const supportsHVLineContainerBBox_ = (function () {
|
|||||||
return (bbox.width === 15);
|
return (bbox.width === 15);
|
||||||
}());
|
}());
|
||||||
|
|
||||||
const supportsEditableText_ = (function () {
|
|
||||||
// TODO: Find better way to check support for this
|
|
||||||
return isOpera_;
|
|
||||||
}());
|
|
||||||
|
|
||||||
const supportsNonScalingStroke_ = (function () {
|
const supportsNonScalingStroke_ = (function () {
|
||||||
const rect = document.createElementNS(NS.SVG, 'rect');
|
const rect = document.createElementNS(NS.SVG, 'rect');
|
||||||
rect.setAttribute('style', 'vector-effect:non-scaling-stroke');
|
rect.setAttribute('style', 'vector-effect:non-scaling-stroke');
|
||||||
@@ -146,11 +121,6 @@ let supportsNativeSVGTransformLists_ = (function () {
|
|||||||
|
|
||||||
// Public API
|
// Public API
|
||||||
|
|
||||||
/**
|
|
||||||
* @function module:browser.isOpera
|
|
||||||
* @returns {boolean}
|
|
||||||
*/
|
|
||||||
export const isOpera = () => isOpera_;
|
|
||||||
/**
|
/**
|
||||||
* @function module:browser.isWebkit
|
* @function module:browser.isWebkit
|
||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
@@ -166,11 +136,7 @@ export const isGecko = () => isGecko_;
|
|||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
export const isChrome = () => isChrome_;
|
export const isChrome = () => isChrome_;
|
||||||
/**
|
|
||||||
* @function module:browser.isWindows
|
|
||||||
* @returns {boolean}
|
|
||||||
*/
|
|
||||||
export const isWindows = () => isWindows_;
|
|
||||||
/**
|
/**
|
||||||
* @function module:browser.isMac
|
* @function module:browser.isMac
|
||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
@@ -182,18 +148,6 @@ export const isMac = () => isMac_;
|
|||||||
*/
|
*/
|
||||||
export const isTouch = () => isTouch_;
|
export const isTouch = () => isTouch_;
|
||||||
|
|
||||||
/**
|
|
||||||
* @function module:browser.supportsSelectors
|
|
||||||
* @returns {boolean}
|
|
||||||
*/
|
|
||||||
export const supportsSelectors = () => supportsSelectors_;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @function module:browser.supportsXpath
|
|
||||||
* @returns {boolean}
|
|
||||||
*/
|
|
||||||
export const supportsXpath = () => supportsXpath_;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @function module:browser.supportsPathReplaceItem
|
* @function module:browser.supportsPathReplaceItem
|
||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
@@ -224,12 +178,6 @@ export const supportsHVLineContainerBBox = () => supportsHVLineContainerBBox_;
|
|||||||
*/
|
*/
|
||||||
export const supportsGoodTextCharPos = () => supportsGoodTextCharPos_;
|
export const supportsGoodTextCharPos = () => supportsGoodTextCharPos_;
|
||||||
|
|
||||||
/**
|
|
||||||
* @function module:browser.supportsEditableText
|
|
||||||
* @returns {boolean}
|
|
||||||
*/
|
|
||||||
export const supportsEditableText = () => supportsEditableText_;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @function module:browser.supportsNonScalingStroke
|
* @function module:browser.supportsNonScalingStroke
|
||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
|
|||||||
@@ -13,8 +13,7 @@ import {
|
|||||||
hasMatrixTransform, transformListToTransform, transformBox
|
hasMatrixTransform, transformListToTransform, transformBox
|
||||||
} from './math.js';
|
} from './math.js';
|
||||||
import {
|
import {
|
||||||
isWebkit, supportsHVLineContainerBBox, supportsPathBBox, supportsXpath,
|
isWebkit, supportsHVLineContainerBBox, supportsPathBBox
|
||||||
supportsSelectors
|
|
||||||
} from '../common/browser.js';
|
} from '../common/browser.js';
|
||||||
import { getClosest, mergeDeep } from '../editor/components/jgraduate/Util.js';
|
import { getClosest, mergeDeep } from '../editor/components/jgraduate/Util.js';
|
||||||
|
|
||||||
@@ -27,8 +26,6 @@ const visElemsArr = visElems.split(',');
|
|||||||
// const hidElems = 'defs,desc,feGaussianBlur,filter,linearGradient,marker,mask,metadata,pattern,radialGradient,stop,switch,symbol,title,textPath';
|
// const hidElems = 'defs,desc,feGaussianBlur,filter,linearGradient,marker,mask,metadata,pattern,radialGradient,stop,switch,symbol,title,textPath';
|
||||||
|
|
||||||
let editorContext_ = null;
|
let editorContext_ = null;
|
||||||
let domdoc_ = null;
|
|
||||||
let domcontainer_ = null;
|
|
||||||
let svgroot_ = null;
|
let svgroot_ = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -92,8 +89,6 @@ let svgroot_ = null;
|
|||||||
*/
|
*/
|
||||||
export const init = function (editorContext) {
|
export const init = function (editorContext) {
|
||||||
editorContext_ = editorContext;
|
editorContext_ = editorContext;
|
||||||
domdoc_ = editorContext.getDOMDocument();
|
|
||||||
domcontainer_ = editorContext.getDOMContainer();
|
|
||||||
svgroot_ = editorContext.getSVGRoot();
|
svgroot_ = editorContext.getSVGRoot();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1229,26 +1224,10 @@ export const getFeGaussianBlur = function (ele) {
|
|||||||
* @param {string} id - String with the element's new ID
|
* @param {string} id - String with the element's new ID
|
||||||
* @returns {?Element}
|
* @returns {?Element}
|
||||||
*/
|
*/
|
||||||
export const getElem = (supportsSelectors())
|
export const getElem = (id) => {
|
||||||
? function (id) {
|
// querySelector lookup
|
||||||
// querySelector lookup
|
return svgroot_.querySelector('#' + id);
|
||||||
return svgroot_.querySelector('#' + id);
|
};
|
||||||
}
|
|
||||||
: supportsXpath()
|
|
||||||
? function (id) {
|
|
||||||
// xpath lookup
|
|
||||||
return domdoc_.evaluate(
|
|
||||||
'svg:svg[@id="svgroot"]//svg:*[@id="' + id + '"]',
|
|
||||||
domcontainer_,
|
|
||||||
function () { return NS.SVG; },
|
|
||||||
9,
|
|
||||||
null
|
|
||||||
).singleNodeValue;
|
|
||||||
}
|
|
||||||
: function (id) {
|
|
||||||
// jQuery lookup: twice as slow as xpath in FF
|
|
||||||
return svgroot_.querySelector(`[id=${id}]`);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assigns multiple attributes to an element.
|
* Assigns multiple attributes to an element.
|
||||||
|
|||||||
Reference in New Issue
Block a user