Last active
August 29, 2015 14:20
-
-
Save DigiTec/3fb42e6edeb4239e43b5 to your computer and use it in GitHub Desktop.
This gist is for my article on how a Browser implements constructors for DOM objects. It contains a short list of samples that are inserted into the article for pretty printing. Here is the link to the article: http://www.justrog.com/2015/05/constructors-by-construction-in.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Per spec configures a location on the global of name Node with a value | |
// of the instance of the function. | |
function ANode() { | |
} | |
// We derive from Object | |
ANode.prototype = Object.create(Object.prototype); | |
// Complete the loop back to ourselves | |
ANode.prototype.constructor = ANode; | |
// Add constants | |
Object.defineProperties(ANode, { | |
ELEMENT_NODE: { | |
value: 1, | |
writable: false, | |
configurable: false | |
}, | |
}); | |
// Add static methods | |
Object.defineProperties(ANode, { | |
create: { | |
value: function create() { | |
return {}; | |
} | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface ANode { | |
const unsigned short ELEMENT_NODE = 1; | |
static Node create(); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Constructor] | |
interface XMLHttpRequest { | |
} | |
[NamedConstructor=Image(optional unsigned long width, optional unsigned long height)] | |
interface HTMLImageElement { | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[msInterfaceObjectOnly] | |
interface MSApp | |
{ | |
const DOMString CURRENT = "current"; | |
const DOMString HIGH = "high"; | |
const DOMString NORMAL = "normal"; | |
const DOMString IDLE = "idle"; | |
static any execAtPriority(MSExecAtPriorityFunctionCallback synchronousCallback, DOMString priority, any... args); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[msInterfaceObjectOnly] | |
interface NodeFilter | |
{ | |
// Constants returned by acceptNode | |
const short FILTER_ACCEPT = 1; | |
const short FILTER_REJECT = 2; | |
const short FILTER_SKIP = 3; | |
// Constants for whatToShow | |
const unsigned long SHOW_ALL = 0xFFFFFFFF; | |
const unsigned long SHOW_ELEMENT = 0x00000001; | |
const unsigned long SHOW_ATTRIBUTE = 0x00000002; | |
const unsigned long SHOW_TEXT = 0x00000004; | |
const unsigned long SHOW_CDATA_SECTION = 0x00000008; | |
const unsigned long SHOW_ENTITY_REFERENCE = 0x00000010; | |
const unsigned long SHOW_ENTITY = 0x00000020; | |
const unsigned long SHOW_PROCESSING_INSTRUCTION = 0x00000040; | |
const unsigned long SHOW_COMMENT = 0x00000080; | |
const unsigned long SHOW_DOCUMENT = 0x00000100; | |
const unsigned long SHOW_DOCUMENT_TYPE = 0x00000200; | |
const unsigned long SHOW_DOCUMENT_FRAGMENT = 0x00000400; | |
const unsigned long SHOW_NOTATION = 0x00000800; | |
short acceptNode(Node n); // This API is ignored in the binding | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment