- Fix: Avoid cross-frame unsafe `instanceof`

- npm: Update eslint-config-ash-nazg
master
Brett Zamir 2018-11-28 08:56:41 +08:00
parent 9f844f6496
commit 99ec41a3c3
18 changed files with 95 additions and 33 deletions

View File

@ -2,8 +2,13 @@
# ?
- Fix: Avoid cross-frame unsafe `instanceof`
- Enhancement: Add svgcanvas distributions
- Update: Bump StackBlur version
- Demo: Rename import to match named dist export
- Linting (ESLint): Prefer `addEventListener`, exponentiation operator,
avoiding catastrophic regexes, prefer spread, prefer
`startsWith`/`endsWith`, no fn ref in iterator
- npm: Update devDeps
# 4.0.1

17
dist/dom-polyfill.js vendored
View File

@ -1,6 +1,20 @@
(function () {
'use strict';
function _typeof(obj) {
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
_typeof = function (obj) {
return typeof obj;
};
} else {
_typeof = function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
}
return _typeof(obj);
}
// From https://github.com/inexorabletash/polyfill/blob/master/dom.js
/**
@ -37,7 +51,8 @@
function convertNodesIntoANode(nodes) {
nodes = nodes.map(function (node) {
return !(node instanceof Node) ? document.createTextNode(node) : node;
var isNode = node && _typeof(node) === 'object' && 'nodeType' in node;
return isNode ? node : document.createTextNode(node);
});
if (nodes.length === 1) {

10
dist/index-es.js vendored
View File

@ -2626,7 +2626,6 @@ var getReverseNS = function getReverseNS() {
}
})();
/* globals jQuery */
var $ = jQuery;
var supportsSVG_ = function () {
@ -2758,9 +2757,14 @@ var supportsNativeSVGTransformLists_ = function () {
var rxform = rect.transform.baseVal;
var t1 = svg.createSVGTransform();
rxform.appendItem(t1);
var r1 = rxform.getItem(0); // Todo: Do frame-independent instance checking
var r1 = rxform.getItem(0);
return r1 instanceof SVGTransform && t1 instanceof SVGTransform && r1.type === t1.type && r1.angle === t1.angle && r1.matrix.a === t1.matrix.a && r1.matrix.b === t1.matrix.b && r1.matrix.c === t1.matrix.c && r1.matrix.d === t1.matrix.d && r1.matrix.e === t1.matrix.e && r1.matrix.f === t1.matrix.f;
var isSVGTransform = function isSVGTransform(o) {
// https://developer.mozilla.org/en-US/docs/Web/API/SVGTransform
return o && _typeof(o) === 'object' && typeof o.setMatrix === 'function' && 'angle' in o;
};
return isSVGTransform(r1) && isSVGTransform(t1) && r1.type === t1.type && r1.angle === t1.angle && r1.matrix.a === t1.matrix.a && r1.matrix.b === t1.matrix.b && r1.matrix.c === t1.matrix.c && r1.matrix.d === t1.matrix.d && r1.matrix.e === t1.matrix.e && r1.matrix.f === t1.matrix.f;
}(); // Public API
/**

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

10
dist/index-umd.js vendored
View File

@ -2632,7 +2632,6 @@
}
})();
/* globals jQuery */
var $ = jQuery;
var supportsSVG_ = function () {
@ -2764,9 +2763,14 @@
var rxform = rect.transform.baseVal;
var t1 = svg.createSVGTransform();
rxform.appendItem(t1);
var r1 = rxform.getItem(0); // Todo: Do frame-independent instance checking
var r1 = rxform.getItem(0);
return r1 instanceof SVGTransform && t1 instanceof SVGTransform && r1.type === t1.type && r1.angle === t1.angle && r1.matrix.a === t1.matrix.a && r1.matrix.b === t1.matrix.b && r1.matrix.c === t1.matrix.c && r1.matrix.d === t1.matrix.d && r1.matrix.e === t1.matrix.e && r1.matrix.f === t1.matrix.f;
var isSVGTransform = function isSVGTransform(o) {
// https://developer.mozilla.org/en-US/docs/Web/API/SVGTransform
return o && _typeof(o) === 'object' && typeof o.setMatrix === 'function' && 'angle' in o;
};
return isSVGTransform(r1) && isSVGTransform(t1) && r1.type === t1.type && r1.angle === t1.angle && r1.matrix.a === t1.matrix.a && r1.matrix.b === t1.matrix.b && r1.matrix.c === t1.matrix.c && r1.matrix.d === t1.matrix.d && r1.matrix.e === t1.matrix.e && r1.matrix.f === t1.matrix.f;
}(); // Public API
/**

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,20 @@
(function () {
'use strict';
function _typeof(obj) {
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
_typeof = function (obj) {
return typeof obj;
};
} else {
_typeof = function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
}
return _typeof(obj);
}
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
@ -2419,7 +2433,6 @@
};
/* globals jQuery */
var $ = jQuery;
var supportsSVG_ = function () {
@ -2559,9 +2572,14 @@
var rxform = rect.transform.baseVal;
var t1 = svg.createSVGTransform();
rxform.appendItem(t1);
var r1 = rxform.getItem(0); // Todo: Do frame-independent instance checking
var r1 = rxform.getItem(0);
return r1 instanceof SVGTransform && t1 instanceof SVGTransform && r1.type === t1.type && r1.angle === t1.angle && r1.matrix.a === t1.matrix.a && r1.matrix.b === t1.matrix.b && r1.matrix.c === t1.matrix.c && r1.matrix.d === t1.matrix.d && r1.matrix.e === t1.matrix.e && r1.matrix.f === t1.matrix.f;
var isSVGTransform = function isSVGTransform(o) {
// https://developer.mozilla.org/en-US/docs/Web/API/SVGTransform
return o && _typeof(o) === 'object' && typeof o.setMatrix === 'function' && 'angle' in o;
};
return isSVGTransform(r1) && isSVGTransform(t1) && r1.type === t1.type && r1.angle === t1.angle && r1.matrix.a === t1.matrix.a && r1.matrix.b === t1.matrix.b && r1.matrix.c === t1.matrix.c && r1.matrix.d === t1.matrix.d && r1.matrix.e === t1.matrix.e && r1.matrix.f === t1.matrix.f;
}(); // Public API
if (!supportsSvg()) {

View File

@ -2838,7 +2838,6 @@ var SvgCanvas = (function () {
return reverseNS;
};
/* globals jQuery */
var $ = jQuery;
var supportsSVG_ = function () {
@ -2970,9 +2969,14 @@ var SvgCanvas = (function () {
var rxform = rect.transform.baseVal;
var t1 = svg.createSVGTransform();
rxform.appendItem(t1);
var r1 = rxform.getItem(0); // Todo: Do frame-independent instance checking
var r1 = rxform.getItem(0);
return r1 instanceof SVGTransform && t1 instanceof SVGTransform && r1.type === t1.type && r1.angle === t1.angle && r1.matrix.a === t1.matrix.a && r1.matrix.b === t1.matrix.b && r1.matrix.c === t1.matrix.c && r1.matrix.d === t1.matrix.d && r1.matrix.e === t1.matrix.e && r1.matrix.f === t1.matrix.f;
var isSVGTransform = function isSVGTransform(o) {
// https://developer.mozilla.org/en-US/docs/Web/API/SVGTransform
return o && _typeof(o) === 'object' && typeof o.setMatrix === 'function' && 'angle' in o;
};
return isSVGTransform(r1) && isSVGTransform(t1) && r1.type === t1.type && r1.angle === t1.angle && r1.matrix.a === t1.matrix.a && r1.matrix.b === t1.matrix.b && r1.matrix.c === t1.matrix.c && r1.matrix.d === t1.matrix.d && r1.matrix.e === t1.matrix.e && r1.matrix.f === t1.matrix.f;
}(); // Public API
/**

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -152,8 +152,11 @@ const rxform = rect.transform.baseVal;
const t1 = svg.createSVGTransform();
rxform.appendItem(t1);
const r1 = rxform.getItem(0);
// Todo: Do frame-independent instance checking
return r1 instanceof SVGTransform && t1 instanceof SVGTransform &&
const isSVGTransform = (o) => {
// https://developer.mozilla.org/en-US/docs/Web/API/SVGTransform
return o && typeof o === 'object' && typeof o.setMatrix === 'function' && 'angle' in o;
};
return isSVGTransform(r1) && isSVGTransform(t1) &&
r1.type === t1.type && r1.angle === t1.angle &&
r1.matrix.a === t1.matrix.a &&
r1.matrix.b === t1.matrix.b &&

View File

@ -34,7 +34,8 @@ function mixin (o, ps) {
*/
function convertNodesIntoANode (nodes) {
nodes = nodes.map((node) => {
return !(node instanceof Node) ? document.createTextNode(node) : node;
const isNode = node && typeof node === 'object' && 'nodeType' in node;
return isNode ? node : document.createTextNode(node);
});
if (nodes.length === 1) {
return nodes[0];

View File

@ -2629,7 +2629,6 @@
}
})();
/* globals jQuery */
var $ = jQuery;
var supportsSVG_ = function () {
@ -2761,9 +2760,14 @@
var rxform = rect.transform.baseVal;
var t1 = svg.createSVGTransform();
rxform.appendItem(t1);
var r1 = rxform.getItem(0); // Todo: Do frame-independent instance checking
var r1 = rxform.getItem(0);
return r1 instanceof SVGTransform && t1 instanceof SVGTransform && r1.type === t1.type && r1.angle === t1.angle && r1.matrix.a === t1.matrix.a && r1.matrix.b === t1.matrix.b && r1.matrix.c === t1.matrix.c && r1.matrix.d === t1.matrix.d && r1.matrix.e === t1.matrix.e && r1.matrix.f === t1.matrix.f;
var isSVGTransform = function isSVGTransform(o) {
// https://developer.mozilla.org/en-US/docs/Web/API/SVGTransform
return o && _typeof(o) === 'object' && typeof o.setMatrix === 'function' && 'angle' in o;
};
return isSVGTransform(r1) && isSVGTransform(t1) && r1.type === t1.type && r1.angle === t1.angle && r1.matrix.a === t1.matrix.a && r1.matrix.b === t1.matrix.b && r1.matrix.c === t1.matrix.c && r1.matrix.d === t1.matrix.d && r1.matrix.e === t1.matrix.e && r1.matrix.f === t1.matrix.f;
}(); // Public API
/**

6
package-lock.json generated
View File

@ -3775,9 +3775,9 @@
}
},
"eslint-config-ash-nazg": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/eslint-config-ash-nazg/-/eslint-config-ash-nazg-0.1.1.tgz",
"integrity": "sha512-iUDDkx0newCYMeuR+taRInJL2ONAXfvx5+b2CRMD0u+MUffLMP4bNY99C4GuGkD0gQ3/0a/VD7AQj7wE4KXmEQ==",
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/eslint-config-ash-nazg/-/eslint-config-ash-nazg-0.2.0.tgz",
"integrity": "sha512-KEqkn2uxjyfY6RRtVcceL9XG/Ds3iWS1uwQ9Ltldi+u+I/h76arGrETwu7mSOQroB8AvLuy/bAhLf6FM8tUnbg==",
"dev": true
},
"eslint-config-standard": {

View File

@ -84,7 +84,7 @@
"axe-testcafe": "^1.1.0",
"babel-plugin-transform-object-rest-spread": "^7.0.0-beta.3",
"eslint": "5.9.0",
"eslint-config-ash-nazg": "0.1.1",
"eslint-config-ash-nazg": "0.2.0",
"eslint-config-standard": "12.0.0",
"eslint-plugin-compat": "2.6.3",
"eslint-plugin-import": "2.14.0",

View File

@ -2629,7 +2629,6 @@
}
})();
/* globals jQuery */
var $ = jQuery;
var supportsSVG_ = function () {
@ -2761,9 +2760,14 @@
var rxform = rect.transform.baseVal;
var t1 = svg.createSVGTransform();
rxform.appendItem(t1);
var r1 = rxform.getItem(0); // Todo: Do frame-independent instance checking
var r1 = rxform.getItem(0);
return r1 instanceof SVGTransform && t1 instanceof SVGTransform && r1.type === t1.type && r1.angle === t1.angle && r1.matrix.a === t1.matrix.a && r1.matrix.b === t1.matrix.b && r1.matrix.c === t1.matrix.c && r1.matrix.d === t1.matrix.d && r1.matrix.e === t1.matrix.e && r1.matrix.f === t1.matrix.f;
var isSVGTransform = function isSVGTransform(o) {
// https://developer.mozilla.org/en-US/docs/Web/API/SVGTransform
return o && _typeof(o) === 'object' && typeof o.setMatrix === 'function' && 'angle' in o;
};
return isSVGTransform(r1) && isSVGTransform(t1) && r1.type === t1.type && r1.angle === t1.angle && r1.matrix.a === t1.matrix.a && r1.matrix.b === t1.matrix.b && r1.matrix.c === t1.matrix.c && r1.matrix.d === t1.matrix.d && r1.matrix.e === t1.matrix.e && r1.matrix.f === t1.matrix.f;
}(); // Public API
/**