Objekt durchlaufen - object doesn't support this action
kati
- javascript
Hallo,
ich habe ein Paar einfache reflection-Klassen programmiert, mit denen ich mir die Struktur von Objekten anschauen kann. Ich bilde mir ein, dass seit dem letzten Windows Update an dieser Stelle eine JS-Exception geworfen wird:
Object doesn't support this action.
Im Grunde genommen laufe ich ein Objekt mit foreach durch und hole mit die Eigenschaften- bzw. Methodennamen und deren Werte bzw. Methodenrumpfe.
Field.prototype.getValue = function() {
if( ! DataTypeUtils.isObject( this.field ) ) return this.field;
var value = "";
try {
var i=0;
for( var member in this.field ) {
try {
if(i>0) value += ",";
value += this.lineSep;
value += "---[" + member + "=" + this.field[member] + "]";
i++;
} catch(e) {
value += "---[error while fetching information about " + member + ":" + e.message + "]";
}
}
} catch(e) {
var errDesc = "";
try {
errDesc = DataTypeUtils.isString(e) ? e : e.message;
} catch(ex) {
}
return "exception (" + errDesc + ") thrown during fetching information about value: " + value;
}
return value;
}
Wenn ich an die zuständige Methode eben ein XMLDocument (das übliche: xmlHttp.responseXML ) übermittle, wird gleich eine Exception (siehe oben) geschmissen. Im FF, Opera etc. funktioniert alles wie immer. Es ist schon klar, dass aus Sicherheitsgründen auf manche Eigenschaften nicht zugegriffen werden kann, das wird auch schon im inneren try-catch-Block abgefangen.
Das XMLDocument müsste so bzw. so ähnlich (=Firefox-Ergebnis) aussehen:
DEBUG:type=[XMLDocument];
value=
---[constructor=[XMLDocument]],
---[load=function load() {
[native code]
}],
---[nodeName=#document],
---[nodeValue=null],
---[nodeType=9],
---[parentNode=null],
---[childNodes=[object NodeList]],
---[firstChild=[object Element]],
---[lastChild=[object Element]],
---[previousSibling=null],
---[nextSibling=null],
---[attributes=null],
---[ownerDocument=null],
---[insertBefore=function insertBefore() {
[native code]
}],
---[replaceChild=function replaceChild() {
[native code]
}],
---[removeChild=function removeChild() {
[native code]
}],
---[appendChild=function appendChild() {
[native code]
}],
---[hasChildNodes=function hasChildNodes() {
[native code]
}],
---[cloneNode=function cloneNode() {
[native code]
}],
---[normalize=function normalize() {
[native code]
}],
---[isSupported=function isSupported() {
[native code]
}],
---[namespaceURI=null],
---[prefix=null],
---[localName=null],
---[hasAttributes=function hasAttributes() {
[native code]
}],
---[doctype=null],
---[implementation=[object DOMImplementation]],
---[documentElement=[object Element]],
---[createElement=function createElement() {
[native code]
}],
---[createDocumentFragment=function createDocumentFragment() {
[native code]
}],
---[createTextNode=function createTextNode() {
[native code]
}],
---[createComment=function createComment() {
[native code]
}],
---[createCDATASection=function createCDATASection() {
[native code]
}],
---[createProcessingInstruction=function createProcessingInstruction() {
[native code]
}],
---[createAttribute=function createAttribute() {
[native code]
}],
---[createEntityReference=function createEntityReference() {
[native code]
}],
---[getElementsByTagName=function getElementsByTagName() {
[native code]
}],
---[importNode=function importNode() {
[native code]
}],
---[createElementNS=function createElementNS() {
[native code]
}],
---[createAttributeNS=function createAttributeNS() {
[native code]
}],
---[getElementsByTagNameNS=function getElementsByTagNameNS() {
[native code]
}],
---[getElementById=function getElementById() {
[native code]
}],
---[ELEMENT_NODE=1],
---[ATTRIBUTE_NODE=2],
---[TEXT_NODE=3],
---[CDATA_SECTION_NODE=4],
---[ENTITY_REFERENCE_NODE=5],
---[ENTITY_NODE=6],
---[PROCESSING_INSTRUCTION_NODE=7],
---[COMMENT_NODE=8],
---[DOCUMENT_NODE=9],
---[DOCUMENT_TYPE_NODE=10],
---[DOCUMENT_FRAGMENT_NODE=11],
---[NOTATION_NODE=12],
---[async=true],
---[evaluateFIXptr=function evaluateFIXptr() {
[native code]
}],
---[evaluateXPointer=function evaluateXPointer() {
[native code]
}],
---[characterSet=windows-1252],
---[dir=],
---[title=],
---[contentType=text/xml],
---[lastModified=07/14/2008 14:22:57],
---[referrer=http://localhost/jscore/unittests/_unit__de_wigeogis_general_util_WGGXmlUtils.html?cacheBuster=1216038175818],
---[getBoxObjectFor=function getBoxObjectFor() {
[native code]
}],
---[setBoxObjectFor=function setBoxObjectFor() {
[native code]
}],
---[createEvent=function createEvent() {
[native code]
}],
---[styleSheets=[object StyleSheetList]],
---[preferredStylesheetSet=],
---[defaultView=null],
---[createRange=function createRange() {
[native code]
}],
---[createNodeIterator=function createNodeIterator() {
[native code]
}],
---[createTreeWalker=function createTreeWalker() {
[native code]
}],
---[getAnonymousNodes=function getAnonymousNodes() {
[native code]
}],
---[getAnonymousElementByAttribute=function getAnonymousElementByAttribute() {
[native code]
}],
---[addBinding=function addBinding() {
[native code]
}],
---[removeBinding=function removeBinding() {
[native code]
}],
---[getBindingParent=function getBindingParent() {
[native code]
}],
---[loadBindingDocument=function loadBindingDocument() {
[native code]
}],
---[removeEventListener=function removeEventListener() {
[native code]
}],
---[dispatchEvent=function dispatchEvent() {
[native code]
}],
---[baseURI=http://localhost/index.php5],
---[compareDocumentPosition=function compareDocumentPosition() {
[native code]
}],
---[textContent=null],
---[isSameNode=function isSameNode() {
[native code]
}],
---[lookupPrefix=function lookupPrefix() {
[native code]
}],
---[isDefaultNamespace=function isDefaultNamespace() {
[native code]
}],
---[lookupNamespaceURI=function lookupNamespaceURI() {
[native code]
}],
---[isEqualNode=function isEqualNode() {
[native code]
}],
---[getFeature=function getFeature() {
[native code]
}],
---[setUserData=function setUserData() {
[native code]
}],
---[getUserData=function getUserData() {
[native code]
}],
---[inputEncoding=windows-1252],
---[xmlEncoding=windows-1252],
---[xmlStandalone=false],
---[xmlVersion=1.0],
---[strictErrorChecking=true],
---[documentURI=http://localhost/index.php5],
---[adoptNode=function adoptNode() {
[native code]
}],
---[error while fetching information about domConfig:Component returned failure code: 0x80004001 (NS_ERROR_NOT_IMPLEMENTED) [nsIDOM3Document.domConfig]],
---[normalizeDocument=function normalizeDocument() {
[native code]
}],
---[renameNode=function renameNode() {
[native code]
}],
---[DOCUMENT_POSITION_DISCONNECTED=1],
---[DOCUMENT_POSITION_PRECEDING=2],
---[DOCUMENT_POSITION_FOLLOWING=4],
---[DOCUMENT_POSITION_CONTAINS=8],
---[DOCUMENT_POSITION_CONTAINED_BY=16],
---[DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC=32],
---[createExpression=function createExpression() {
[native code]
}],
---[createNSResolver=function createNSResolver() {
[native code]
}],
---[evaluate=function evaluate() {
[native code]
}]
kati