From a7afbb1f1bcc0760df8f7b3de793693a851fb20f Mon Sep 17 00:00:00 2001 From: alexcjohnson Date: Tue, 20 Jun 2017 12:00:25 -0400 Subject: [PATCH] :hocho: node.children --- src/components/drawing/index.js | 4 ++-- tasks/test_syntax.js | 30 ++++++++++++++++++------------ 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/src/components/drawing/index.js b/src/components/drawing/index.js index 3ce00f296a7..c2e2540ef97 100644 --- a/src/components/drawing/index.js +++ b/src/components/drawing/index.js @@ -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) { diff --git a/tasks/test_syntax.js b/tasks/test_syntax.js index 1c928211da3..c00daed44c0 100644 --- a/tasks/test_syntax.js +++ b/tasks/test_syntax.js @@ -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'); @@ -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)'); } } });