MCPcopy Index your code
hub / github.com/nodejs/node / is_node

Function is_node

test/fixtures/wpt/resources/testharness.js:1315–1342  ·  view source on GitHub ↗
(object)

Source from the content-addressed store, hash-verified

1313 * Return true if object is probably a Node object.
1314 */
1315 function is_node(object)
1316 {
1317 // I use duck-typing instead of instanceof, because
1318 // instanceof doesn't work if the node is from another window (like an
1319 // iframe's contentWindow):
1320 // http://www.w3.org/Bugs/Public/show_bug.cgi?id=12295
1321 try {
1322 var has_node_properties = ("nodeType" in object &&
1323 "nodeName" in object &&
1324 "nodeValue" in object &&
1325 "childNodes" in object);
1326 } catch (e) {
1327 // We're probably cross-origin, which means we aren't a node
1328 return false;
1329 }
1330
1331 if (has_node_properties) {
1332 try {
1333 object.nodeType;
1334 } catch (e) {
1335 // The object is probably Node.prototype or another prototype
1336 // object that inherits from it, and not a Node instance.
1337 return false;
1338 }
1339 return true;
1340 }
1341 return false;
1342 }
1343
1344 var replacements = {
1345 "0": "0",

Callers 1

format_valueFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected