Skip to content

Take out node.children #1803

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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