Skip to content

Commit

Permalink
Merge pull request #1803 from plotly/childnodes
Browse files Browse the repository at this point in the history
Take out node.children
  • Loading branch information
alexcjohnson authored Jun 20, 2017
2 parents cb026fe + a7afbb1 commit 092890f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/components/drawing/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -634,14 +634,14 @@ drawing.bBox = function(node, hash) {
out = drawing.savedBBoxes[hash];
if(out) return Lib.extendFlat({}, out);
}
else if(node.children.length === 1) {
else if(node.childNodes.length === 1) {
/*
* If we have only one child element, which is itself hashable, make
* a new hash from this element plus its x,y,transform
* These bounding boxes *include* x,y,transform - mostly for use by
* callers trying to avoid overlaps (ie titles)
*/
var innerNode = node.children[0];
var innerNode = node.childNodes[0];

hash = nodeHash(innerNode);
if(hash) {
Expand Down
30 changes: 18 additions & 12 deletions tasks/test_syntax.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@ function assertSrcContents() {
var licenseStr = licenseSrc.substring(2, licenseSrc.length - 2);
var logs = [];

// These are forbidden in IE *only in SVG* but since
// that's 99% of what we do here, we'll forbid them entirely
// until there's some HTML use case where we need them.
// (not sure what we'd do then, but we'd think of something!)
var IE_SVG_BLACK_LIST = ['innerHTML', 'parentElement', 'children'];

// Forbidden in IE in any context
var IE_BLACK_LIST = ['classList'];

glob(combineGlobs([srcGlob, libGlob]), function(err, files) {
files.forEach(function(file) {
var code = fs.readFileSync(file, 'utf-8');
Expand All @@ -69,21 +78,18 @@ function assertSrcContents() {
falafel(code, {onComment: comments, locations: true}, function(node) {
// look for .classList
if(node.type === 'MemberExpression') {
var parts = node.source().split('.');
var source = node.source();
var parts = source.split('.');
var lastPart = parts[parts.length - 1];
if(lastPart === 'classList') {
logs.push(file + ' : contains .classList (IE failure)');
}
else if(lastPart === 'innerHTML') {
// Note: if we do anything that's NOT in SVG, innerHTML is
// OK in IE. We can cross that bridge when we get to it...
logs.push(file + ' : contains .innerHTML (IE failure in SVG)');

if(source === 'Math.sign') {
logs.push(file + ' : contains Math.sign (IE failure)');
}
else if(lastPart === 'parentElement') {
logs.push(file + ' : contains .parentElement (IE failure)');
else if(IE_BLACK_LIST.indexOf(lastPart) !== -1) {
logs.push(file + ' : contains .' + lastPart + ' (IE failure)');
}
else if(node.source() === 'Math.sign') {
logs.push(file + ' : contains Math.sign (IE failure)');
else if(IE_SVG_BLACK_LIST.indexOf(lastPart) !== -1) {
logs.push(file + ' : contains .' + lastPart + ' (IE failure in SVG)');
}
}
});
Expand Down

0 comments on commit 092890f

Please sign in to comment.