Skip to content

Commit 092890f

Browse files
authored
Merge pull request #1803 from plotly/childnodes
Take out node.children
2 parents cb026fe + a7afbb1 commit 092890f

File tree

2 files changed

+20
-14
lines changed

2 files changed

+20
-14
lines changed

src/components/drawing/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -634,14 +634,14 @@ drawing.bBox = function(node, hash) {
634634
out = drawing.savedBBoxes[hash];
635635
if(out) return Lib.extendFlat({}, out);
636636
}
637-
else if(node.children.length === 1) {
637+
else if(node.childNodes.length === 1) {
638638
/*
639639
* If we have only one child element, which is itself hashable, make
640640
* a new hash from this element plus its x,y,transform
641641
* These bounding boxes *include* x,y,transform - mostly for use by
642642
* callers trying to avoid overlaps (ie titles)
643643
*/
644-
var innerNode = node.children[0];
644+
var innerNode = node.childNodes[0];
645645

646646
hash = nodeHash(innerNode);
647647
if(hash) {

tasks/test_syntax.js

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,15 @@ function assertSrcContents() {
6060
var licenseStr = licenseSrc.substring(2, licenseSrc.length - 2);
6161
var logs = [];
6262

63+
// These are forbidden in IE *only in SVG* but since
64+
// that's 99% of what we do here, we'll forbid them entirely
65+
// until there's some HTML use case where we need them.
66+
// (not sure what we'd do then, but we'd think of something!)
67+
var IE_SVG_BLACK_LIST = ['innerHTML', 'parentElement', 'children'];
68+
69+
// Forbidden in IE in any context
70+
var IE_BLACK_LIST = ['classList'];
71+
6372
glob(combineGlobs([srcGlob, libGlob]), function(err, files) {
6473
files.forEach(function(file) {
6574
var code = fs.readFileSync(file, 'utf-8');
@@ -69,21 +78,18 @@ function assertSrcContents() {
6978
falafel(code, {onComment: comments, locations: true}, function(node) {
7079
// look for .classList
7180
if(node.type === 'MemberExpression') {
72-
var parts = node.source().split('.');
81+
var source = node.source();
82+
var parts = source.split('.');
7383
var lastPart = parts[parts.length - 1];
74-
if(lastPart === 'classList') {
75-
logs.push(file + ' : contains .classList (IE failure)');
76-
}
77-
else if(lastPart === 'innerHTML') {
78-
// Note: if we do anything that's NOT in SVG, innerHTML is
79-
// OK in IE. We can cross that bridge when we get to it...
80-
logs.push(file + ' : contains .innerHTML (IE failure in SVG)');
84+
85+
if(source === 'Math.sign') {
86+
logs.push(file + ' : contains Math.sign (IE failure)');
8187
}
82-
else if(lastPart === 'parentElement') {
83-
logs.push(file + ' : contains .parentElement (IE failure)');
88+
else if(IE_BLACK_LIST.indexOf(lastPart) !== -1) {
89+
logs.push(file + ' : contains .' + lastPart + ' (IE failure)');
8490
}
85-
else if(node.source() === 'Math.sign') {
86-
logs.push(file + ' : contains Math.sign (IE failure)');
91+
else if(IE_SVG_BLACK_LIST.indexOf(lastPart) !== -1) {
92+
logs.push(file + ' : contains .' + lastPart + ' (IE failure in SVG)');
8793
}
8894
}
8995
});

0 commit comments

Comments
 (0)