Moodle

Javascript lib DOM processing error in fix_column_width

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Won't Fix
  • Affects Version/s: 1.6
  • Fix Version/s: None
  • Component/s: Libraries
  • Labels:
    None
  • Affected Branches:
    MOODLE_16_STABLE

Description

Missing node type checking in javascript-static.js fix_column_width.

in "lib/javascript-static.js" there is a bug when fixing column widths leading to javascript errors. It occurs when filtering a nodes collection for classnames. In some cases column.childNodes may include not only element nodes but also text nodes that have no className property.

The following improved function solved that issue along with more precise way of checking for class name.

function fix_column_width(colName) {
var column = document.getElementById(colName);
var i, node, nodes, children = [], maxwidth = 0, classname;
var regexp = new RegExp("(^|
s)" + "sideblock" + "(
s|$)");
if (!column) {
} else if (!column.offsetWidth) {
window.setTimeout(function () { fix_column_width(colName); }, 20);
} else {
nodes = column.childNodes;
// filter for children and get max col width
for (i = nodes.length; i-- {
node = nodes[i];
classname = node.className;
if (!classname || !regexp.test(classname)) { continue; }
children.push(node);
maxwidth = Math.max(maxwidth, node.offsetWidth);
}
// apply max col width
for (i = children.length; i--; ) { children[i].style.width = maxwidth + 'px'; }
}
}

Activity

Hide
Michael de Raadt added a comment -

Thanks for reporting this issue.

We have detected that this issue has been inactive for over a year has been recorded as affecting versions that are no longer supported.

If you believe that this issue is still relevant to current versions (2.1 and beyond), please comment on the issue. Issues left inactive for a further month will be closed.

Michael d;

lqjjLKA0p6

Show
Michael de Raadt added a comment - Thanks for reporting this issue. We have detected that this issue has been inactive for over a year has been recorded as affecting versions that are no longer supported. If you believe that this issue is still relevant to current versions (2.1 and beyond), please comment on the issue. Issues left inactive for a further month will be closed. Michael d; lqjjLKA0p6
Hide
Michael de Raadt added a comment -

I'm closing this issue as it has become inactive and does not appear to affect a current supported version. If you are encountering this problem or one similar, please launch a new issue.

Show
Michael de Raadt added a comment - I'm closing this issue as it has become inactive and does not appear to affect a current supported version. If you are encountering this problem or one similar, please launch a new issue.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: