Skip to content

Commit

Permalink
fix interfaces for br,dl,h1[1-6],hr,htm,li,ol,ul,td,th,map,meta,object
Browse files Browse the repository at this point in the history
  • Loading branch information
client9 committed Mar 26, 2010
1 parent 4fa4d74 commit 1bebf18
Show file tree
Hide file tree
Showing 13 changed files with 297 additions and 58 deletions.
7 changes: 7 additions & 0 deletions build.xml
Expand Up @@ -395,26 +395,32 @@
<fileset dir="${SRC_DIR}" includes="html/base.js" />
<fileset dir="${SRC_DIR}" includes="html/blockquote-q.js" />
<fileset dir="${SRC_DIR}" includes="html/body.js" />
<fileset dir="${SRC_DIR}" includes="html/br.js" />
<fileset dir="${SRC_DIR}" includes="html/button.js" />
<fileset dir="${SRC_DIR}" includes="html/canvas.js" />
<fileset dir="${SRC_DIR}" includes="html/col-colgroup.js" />
<fileset dir="${SRC_DIR}" includes="html/del-ins.js" />
<fileset dir="${SRC_DIR}" includes="html/div.js" />
<fileset dir="${SRC_DIR}" includes="html/dl.js" />
<fileset dir="${SRC_DIR}" includes="html/legend.js" />
<fileset dir="${SRC_DIR}" includes="html/fieldset.js" />
<fileset dir="${SRC_DIR}" includes="html/form.js" />
<fileset dir="${SRC_DIR}" includes="html/frame.js" />
<fileset dir="${SRC_DIR}" includes="html/frameset.js" />
<fileset dir="${SRC_DIR}" includes="html/h1.js" />
<fileset dir="${SRC_DIR}" includes="html/head.js" />
<fileset dir="${SRC_DIR}" includes="html/html.js" />
<fileset dir="${SRC_DIR}" includes="html/iframe.js" />
<fileset dir="${SRC_DIR}" includes="html/image.js" />
<fileset dir="${SRC_DIR}" includes="html/img.js" />
<fileset dir="${SRC_DIR}" includes="html/input.js" />
<fileset dir="${SRC_DIR}" includes="html/label.js" />
<fileset dir="${SRC_DIR}" includes="html/li.js" />
<fileset dir="${SRC_DIR}" includes="html/link.js" />
<fileset dir="${SRC_DIR}" includes="html/map.js" />
<fileset dir="${SRC_DIR}" includes="html/meta.js" />
<fileset dir="${SRC_DIR}" includes="html/object.js" />
<fileset dir="${SRC_DIR}" includes="html/ol.js" />
<fileset dir="${SRC_DIR}" includes="html/optgroup.js" />
<fileset dir="${SRC_DIR}" includes="html/option.js" />
<fileset dir="${SRC_DIR}" includes="html/p.js" />
Expand All @@ -428,6 +434,7 @@
<fileset dir="${SRC_DIR}" includes="html/textarea.js" />
<fileset dir="${SRC_DIR}" includes="html/title.js" />
<fileset dir="${SRC_DIR}" includes="html/tr.js" />
<fileset dir="${SRC_DIR}" includes="html/ul.js" />
<fileset dir="${SRC_DIR}" includes="html/unknown.js" />
<fileset dir="${SRC_DIR}" includes="common/outro.js" />
</concat>
Expand Down
21 changes: 16 additions & 5 deletions src/html/__global__.js
@@ -1,10 +1,9 @@
/*
* Envjs @VERSION@
* Pure JavaScript Browser Environment
* By John Resig <http://ejohn.org/> and the Envjs Team
* Copyright 2008-2010 John Resig, under the MIT License
*
* This file simply provides the global definitions we need to
*
* This file simply provides the global definitions we need to
* be able to correctly implement to core browser DOM HTML interfaces.
*/
var HTMLDocument,
Expand All @@ -15,36 +14,48 @@ var HTMLDocument,
HTMLBaseElement,
HTMLQuoteElement,
HTMLBodyElement,
HTMLBRElement,
HTMLButtonElement,
HTMLCanvasElement,
HTMLTableColElement,
HTMLModElement,
HTMLDivElement,
HTMLDListElement,
HTMLFieldSetElement,
HTMLFormElement,
HTMLFrameElement,
HTMLFrameSetElement,
HTMLHeadElement,
HTMLHeadingElement,
HTMLHRElement,
HTMLHtmlElement,
HTMLIFrameElement,
HTMLImageElement,
HTMLInputElement,
HTMLLabelElement,
HTMLLegendElement,
HTMLLIElement,
HTMLLinkElement,
HTMLMapElement,
HTMLMetaElement,
HTMLObjectElement,
HTMLOListElement,
HTMLOptGroupElement,
HTMLOptionElement,
HTMLParamElement,
HTMLPreElement,
HTMLScriptElement,
HTMLSelectElement,
HTMLStyleElement,
HTMLTableElement,
HTMLTableSectionElement,
HTMLTableCellElement,
HTMLTableDataCellElement,
HTMLTableHeaderCellElement,
HTMLTableRowElement,
HTMLTextAreaElement,
HTMLTitleElement,
HTMLUnknownElement;

HTMLUListElement,
HTMLUnknownElement,
Image,
Option;
20 changes: 20 additions & 0 deletions src/html/br.js
@@ -0,0 +1,20 @@

/*
* HTMLBRElement
* HTML5: 4.5.3 The hr Element
* http://dev.w3.org/html5/spec/Overview.html#the-br-element
*/
HTMLBRElement = function(ownerDocument) {
HTMLElement.apply(this, arguments);
};

HTMLBRElement.prototype = new HTMLElement;
__extend__(HTMLBRElement.prototype, {

// no additional properties or elements

toString: function() {
return '[object HTMLBRElement]';
}
});

20 changes: 20 additions & 0 deletions src/html/dl.js
@@ -0,0 +1,20 @@

/*
* HTMLDListElement
* HTML5: 4.5.7 The dl Element
* http://dev.w3.org/html5/spec/Overview.html#the-dl-element
*/
HTMLDListElement = function(ownerDocument) {
HTMLElement.apply(this, arguments);
};

HTMLDListElement.prototype = new HTMLElement;
__extend__(HTMLDListElement.prototype, {

// no additional properties or elements

toString: function() {
return '[object HTMLDListElement]';
}
});

84 changes: 46 additions & 38 deletions src/html/document.js
Expand Up @@ -21,7 +21,7 @@ __extend__(HTMLDocument.prototype, {
createElement: function(tagName){
tagName = tagName.toUpperCase();
// create Element specifying 'this' as ownerDocument
// This is an html document so we need to use explicit interfaces per the
// This is an html document so we need to use explicit interfaces per the
//TODO: would be much faster as a big switch
switch(tagName){
case "A":
Expand All @@ -37,7 +37,7 @@ __extend__(HTMLDocument.prototype, {
case "BODY":
node = new HTMLBodyElement(this);break;
case "BR":
node = new HTMLElement(this);break;
node = new HTMLBRElement(this);break;
case "BUTTON":
node = new HTMLButtonElement(this);break;
case "CAPTION":
Expand All @@ -53,29 +53,33 @@ __extend__(HTMLDocument.prototype, {
case "DIV":
node = new HTMLDivElement(this);break;
case "DL":
node = new HTMLElement(this);break;
node = new HTMLDListElement(this);break;
case "DT":
node = new HTMLElement(this); break
case "FIELDSET":
node = new HTMLFieldSetElement(this);break;
case "FORM":
node = new HTMLFormElement(this);break;
case "FRAME":
node = new HTMLFrameElement(this);break;
case "H1":
node = new HTMLHeadElement(this);break;
node = new HTMLHeadingElement(this);break;
case "H2":
node = new HTMLHeadElement(this);break;
node = new HTMLHeadingElement(this);break;
case "H3":
node = new HTMLHeadElement(this);break;
node = new HTMLHeadingElement(this);break;
case "H4":
node = new HTMLHeadElement(this);break;
node = new HTMLHeadingElement(this);break;
case "H5":
node = new HTMLHeadElement(this);break;
node = new HTMLHeadingElement(this);break;
case "H6":
node = new HTMLHeadingElement(this);break;
case "HEAD":
node = new HTMLHeadElement(this);break;
case "HR":
node = new HTMLElement(this);break;
node = new HTMLHRElement(this);break;
case "HTML":
node = new HTMLElement(this);break;
node = new HTMLHtmlElement(this);break;
case "IFRAME":
node = new HTMLIFrameElement(this);break;
case "IMG":
Expand All @@ -87,25 +91,27 @@ __extend__(HTMLDocument.prototype, {
case "LEGEND":
node = new HTMLLegendElement(this);break;
case "LI":
node = new HTMLElement(this);break;
node = new HTMLLIElement(this);break;
case "LINK":
node = new HTMLLinkElement(this);break;
case "MAP":
node = new HTMLMapElement(this);break;
case "META":
node = new HTMLObjectElement(this);break;
node = new HTMLMetaElement(this);break;
case "OBJECT":
node = new HTMLMapElement(this);break;
node = new HTMLObjectElement(this);break;
case "OPTGROUP":
node = new HTMLOptGroupElement(this);break;
case "OL":
node = new HTMLOListElement(this); break;
case "OPTION":
node = new HTMLOptionElement(this);break;
case "P":
node = new HTMLParagraphElement(this);break;
case "PARAM":
node = new HTMLParamElement(this);break;
case "PRE":
node = new HTMLElement(this);break;
node = new HTMLPreElement(this);break;
case "SCRIPT":
node = new HTMLScriptElement(this);break;
case "SELECT":
Expand All @@ -121,17 +127,17 @@ __extend__(HTMLDocument.prototype, {
case "THEAD":
node = new HTMLTableSectionElement(this);break;
case "TD":
node = new HTMLTableCellElement(this);break;
node = new HTMLTableDataCellElement(this);break;
case "TH":
node = new HTMLTableCellElement(this);break;
node = new HTMLTableHeaderCellElement(this);break;
case "TEXTAREA":
node = new HTMLTextAreaElement(this);break;
case "TITLE":
node = new HTMLTitleElement(this);break;
case "TR":
node = new HTMLTableRowElement(this);break;
case "UL":
node = new HTMLElement(this);break;
node = new HTMLULElement(this);break;
default:
node = new HTMLUnknownElement(this);
}
Expand Down Expand Up @@ -245,17 +251,17 @@ __extend__(HTMLDocument.prototype, {
*
*/
get location() {
if (this.ownerWindow) {
if (this.ownerWindow) {
return this.ownerWindow.location;
} else {
return this.baseURI;
}
} else {
return this.baseURI;
}
},
set location(url) {
this.baseURI = url;
if (this.ownerWindow) {
this.baseURI = url;
if (this.ownerWindow) {
this.ownerWindow.location = url;
}
}
},

/**
Expand Down Expand Up @@ -307,7 +313,7 @@ __extend__(HTMLDocument.prototype, {
},

get forms(){
return new HTMLCollection(this.getElementsByTagName('form'));
return new HTMLCollection(this.getElementsByTagName('form'));
},
get images(){
return new HTMLCollection(this.getElementsByTagName('img'));
Expand All @@ -327,34 +333,36 @@ __extend__(HTMLDocument.prototype, {
var all = this.getElementsByTagName('*');
for (var i=0; i < all.length; i++) {
node = all[i];
if (node.nodeType == Node.ELEMENT_NODE &&
if (node.nodeType == Node.ELEMENT_NODE &&
node.getAttribute('name') == name) {
retNodes.push(node);
}
}
return retNodes;
},
},
toString: function(){
return "[object HTMLDocument]";
return "[object HTMLDocument]";
},
get innerHTML(){
return this.documentElement.outerHTML;
return this.documentElement.outerHTML;
},

});


Aspect.around({
target: Node,
Aspect.around({
target: Node,
method:"appendChild"
}, function(invocation) {
var event,
okay,
node = invocation.proceed(),
doc = node.ownerDocument;

console.log('element appended: %s %s', node+'', node.namespaceURI);
if((node.nodeType !== Node.ELEMENT_NODE)){
//for now we are only handling element insertions. probably we will need
//to handle text node changes to script tags and changes to src
//to handle text node changes to script tags and changes to src
//attributes
return node;
}
Expand Down Expand Up @@ -453,15 +461,15 @@ Aspect.around({
break;
}//switch on ns
break;
default:
default:
console.log('element appended: %s %s', node+'', node.namespaceURI);
}//switch on doc.parsing
return node;

});

Aspect.around({
target: Node,
Aspect.around({
target: Node,
method:"removeChild"
}, function(invocation) {
var event,
Expand All @@ -470,7 +478,7 @@ Aspect.around({
doc = node.ownerDocument;
if((node.nodeType !== Node.ELEMENT_NODE)){
//for now we are only handling element insertions. probably we will need
//to handle text node changes to script tags and changes to src
//to handle text node changes to script tags and changes to src
//attributes
if(node.nodeType !== Node.DOCUMENT_NODE && node.uuid){
//console.log('removing event listeners, %s', node, node.uuid);
Expand All @@ -479,7 +487,7 @@ Aspect.around({
return node;
}
//console.log('appended html element %s %s %s', node.namespaceURI, node.nodeName, node);

switch(doc.parsing){
case true:
//handled by parser if included
Expand Down Expand Up @@ -521,7 +529,7 @@ Aspect.around({
break;
}//switch on ns
break;
default:
default:
console.log('element appended: %s %s', node+'', node.namespaceURI);
}//switch on doc.parsing
return node;
Expand Down

0 comments on commit 1bebf18

Please sign in to comment.