Closed
Bug 592872
Opened 14 years ago
Closed 12 years ago
Web Console cleanup: NodeFactory redeclares the "factory" function
Categories
(DevTools :: Console, defect)
DevTools
Console
Tracking
(Not tracked)
RESOLVED
FIXED
People
(Reporter: pcwalton, Assigned: msucan)
References
Details
(Whiteboard: [cleanup] [post-fx-4] [console-1] [fixed by bug 673148])
The NodeFactory function in HUDService.jsm looks like this:
function NodeFactory(aFactoryType, aNameSpace, aDocument)
{
// aDocument is presumed to be a XULDocument
if (aFactoryType == "text") {
function factory(aText) {
return aDocument.createTextNode(aText);
}
return factory;
}
else {
if (aNameSpace == "xul") {
function factory(aTag) {
return aDocument.createElement(aTag);
}
return factory;
}
}
}
Redeclaring the "factory" function like this is not actually legal in standard JavaScript. IMHO the functions should have different names.
Updated•14 years ago
|
Whiteboard: [cleanup] [post-fx-4] → [cleanup] [post-fx-4] [console-1]
Comment 1•13 years ago
|
||
The code is now:
function NodeFactory(aFactoryType, ignored, aDocument)
{
// aDocument is presumed to be a XULDocument
if (aFactoryType == "text") {
return function factory(aText)
{
return aDocument.createTextNode(aText);
}
}
else if (aFactoryType == "xul") {
return function factory(aTag)
{
return aDocument.createElement(aTag);
}
}
else {
throw new Error('NodeFactory: Unknown factory type: ' + aFactoryType);
}
}
Which is AFAIK valid.
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → INVALID
Updated•13 years ago
|
Component: Developer Tools → Developer Tools: Console
QA Contact: developer.tools → developer.tools.console
Version: unspecified → Trunk
Assignee | ||
Comment 2•13 years ago
|
||
Sonny: there are two functions in the code you pasted, both are named "factory", which is not legal in standard JavaScript.
The problem is still valid in the current Web Console code.
Status: RESOLVED → REOPENED
Resolution: INVALID → ---
Comment 3•13 years ago
|
||
And even if they were named differently, function declarations in blocks should be avoided:
https://developer.mozilla.org/en/JavaScript/Guide/Functions
Assignee | ||
Comment 4•12 years ago
|
||
This was most-likely fixed by bug 673148.
Assignee: nobody → mihai.sucan
Status: REOPENED → RESOLVED
Closed: 13 years ago → 12 years ago
Resolution: --- → FIXED
Whiteboard: [cleanup] [post-fx-4] [console-1] → [cleanup] [post-fx-4] [console-1] [fixed by bug 673148]
Updated•6 years ago
|
Product: Firefox → DevTools
You need to log in
before you can comment on or make changes to this bug.
Description
•