htmlArea

A directory of browser-based WYSIWYG editors

  MAIN
INDEX
SEARCH
POSTS
WHO'S
ONLINE
LOG
IN

Home: htmlArea 3 (beta): htmlArea 2 & 3 archive (read only): htmlArea v3.0 - Discussion:
Array prototyping bug and suggested fix.


The htmlArea 2 & 3 editors have been discontinued.

We've made these forums available as a read-only reference and knowledge-base for people using or developing editors based on htmlArea 2 or 3.

Anyone who is interested in taking over version 2 or 3 is free to do so. All we ask is that you choose a new name that doesn't have "htmlarea" in it to avoid confusion with this site. We'll even give you a link in the directory to make it easier for people to find you. If you are developing or hosting an htmlArea based-editor under a new name, please submit it to our directory.

 


Anastasiosyal
New User

Dec 17, 2004, 1:57 AM

Post #1 of 1 (843 views)
Shortcut
Array prototyping bug and suggested fix. Can't Post

 
There is a bug with HTMLArea v.3.0 rc1
If the array object has been extended by use of prototyping,
for example: Array.prototype.indexOf = function(idx){bla bla.....}
then we will get very strange errors when the toolbars load

this is because the function that creates the toolbar buttons uses
the statement

for (var j in group), (group is an array)

however prototyped functions appear as array variables.
Therefore, the toolbutton loaders try to load a button named "indexOf"!

This bug affects both the version for Mozilla and IE. It also affects all the plugins that load
toolbuttons, so the plugin code also needs to be fixed


Suggested Fix:

We must check the typeof the variable before creating a toolbar button
Locate the codeblock below in the createButton(txt) function in HTMLArea.js
and add the lines marked in bold. Wink



Code
  

if (typeof group != "function"){
for (var j in group) {
var code = group[j];
if (typeof code == "string") {
if (/^([IT])\[(.*?)\]/.test(code)) {
// special case, create text label
var l7ed = RegExp.$1 == "I"; // localized?
var label = RegExp.$2;
if (l7ed) {
label = HTMLArea.I18N.custom[label];
}
var tb_cell = document.createElement("td");
tb_row.appendChild(tb_cell);
tb_cell.className = "label";
tb_cell.innerHTML = label;
} else {
createButton(code);
}
}
}
}



Anastasios Yalanopoulos

 
 
 


Search for (options)