Skip to content

Commit

Permalink
style: Improve wording and drop some whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
karfau committed Feb 16, 2022
1 parent 75174b8 commit 04c9f26
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 25 deletions.
10 changes: 5 additions & 5 deletions lib/dom-parser.js
Expand Up @@ -155,8 +155,8 @@ function DOMParser(options){
* - Uses the `options` passed to the `DOMParser` constructor to modify the behavior/implementation.
* - Instead of creating a Document containing the error message,
* it triggers `errorHandler`(s) when unexpected input is found, which means it can return `undefined`.
* All error handlers can throw errors, by default only the `fatalError` handler throws (a `ParserError`).
* - All errors thrown during the parsing that are not a `ParserError` are caught and reported using an error handler.
* All error handlers can throw an `Error`, by default only the `fatalError` handler throws (a `ParserError`).
* - All errors thrown during the parsing that are not a `ParserError` are caught and reported using the `error` handler.
* - If no `ParserError` is thrown, this method returns the `DOMHandler.doc`,
* which most likely is the `Document` that has been created during parsing, or `undefined`.
* __**Warning: By configuring a faulty DOMHandler implementation,
Expand Down Expand Up @@ -186,9 +186,9 @@ DOMParser.prototype.parseFromString = function (source, mimeType) {
defaultNSMap.xml = defaultNSMap.xml || NAMESPACE.XML

var domBuilder = new this.domHandler({
mimeType: mimeType,
defaultNamespace: defaultNamespace,
})
mimeType: mimeType,
defaultNamespace: defaultNamespace,
})
var locator = this.locator ? {} : undefined;
if (this.locator) {
domBuilder.setDocumentLocator(locator)
Expand Down
40 changes: 20 additions & 20 deletions lib/dom.js
Expand Up @@ -157,14 +157,14 @@ NodeList.prototype = {
* The number of nodes in the list. The range of valid child node indices is 0 to length-1 inclusive.
* @standard level1
*/
length:0,
length:0,
/**
* Returns the indexth item in the collection. If index is greater than or equal to the number of nodes in the list, this returns null.
* @standard level1
* @param index unsigned long
* @param index unsigned long
* Index into the collection.
* @return Node
* The node at the indexth position in the NodeList, or null if that is not a valid index.
* The node at the indexth position in the NodeList, or null if that is not a valid index.
*/
item: function(index) {
return this[index] || null;
Expand Down Expand Up @@ -208,7 +208,7 @@ _extends(LiveNodeList,NodeList);
* but this is simply to allow convenient enumeration of the contents of a NamedNodeMap,
* and does not imply that the DOM specifies an order to these Nodes.
* NamedNodeMap objects in the DOM are live.
* used for attributes or DocumentType entities
* used for attributes or DocumentType entities
*/
function NamedNodeMap() {
};
Expand Down Expand Up @@ -297,10 +297,10 @@ NamedNodeMap.prototype = {
var attr = this.getNamedItem(key);
_removeNamedNode(this._ownerElement,this,attr);
return attr;


},// raises: NOT_FOUND_ERR,NO_MODIFICATION_ALLOWED_ERR

//for level2
removeNamedItemNS:function(namespaceURI,localName){
var attr = this.getNamedItemNS(namespaceURI,localName);
Expand Down Expand Up @@ -362,7 +362,7 @@ DOMImplementation.prototype = {
* __It behaves slightly different from the description in the living standard__:
* - There is no interface/class `XMLDocument`, it returns a `Document` instance (with it's `type` set to `'xml'`).
* - `encoding`, `mode`, `origin`, `url` fields are currently not declared.
* - This methods provided by this implementation are not validating names or qualified names.
* - The methods provided by this implementation are not validating names or qualified names.
* (They are only validated by the SAX parser when calling `DOMParser.parseFromString`)
*
* @param {string | null} namespaceURI
Expand Down Expand Up @@ -488,10 +488,10 @@ Node.prototype = {
prefix : null,
localName : null,
// Modified in DOM Level 2:
insertBefore:function(newChild, refChild){//raises
insertBefore:function(newChild, refChild){//raises
return _insertBefore(this,newChild,refChild);
},
replaceChild:function(newChild, oldChild){//raises
replaceChild:function(newChild, oldChild){//raises
this.insertBefore(newChild,oldChild);
if(oldChild){
this.removeChild(oldChild);
Expand Down Expand Up @@ -757,8 +757,8 @@ function _insertBefore(parentNode,newChild,nextChild){

newFirst.previousSibling = pre;
newLast.nextSibling = nextChild;


if(pre){
pre.nextSibling = newFirst;
}else{
Expand Down Expand Up @@ -1220,7 +1220,7 @@ CharacterData.prototype = {
},
insertData: function(offset,text) {
this.replaceData(offset,0,text);

},
appendChild:function(newChild){
throw new Error(ExceptionMessage[HIERARCHY_REQUEST_ERR])
Expand Down Expand Up @@ -1314,7 +1314,7 @@ function nodeSerializeToString(isHtml,nodeFilter){
var refNode = this.nodeType === DOCUMENT_NODE && this.documentElement || this;
var prefix = refNode.prefix;
var uri = refNode.namespaceURI;

if(uri && prefix == null){
//console.log(prefix)
var prefix = refNode.lookupPrefix(uri);
Expand Down Expand Up @@ -1347,8 +1347,8 @@ function needNamespaceDefine(node, isHTML, visibleNamespaces) {
if (prefix === "xml" && uri === NAMESPACE.XML || uri === NAMESPACE.XMLNS) {
return false;
}
var i = visibleNamespaces.length

var i = visibleNamespaces.length
while (i--) {
var ns = visibleNamespaces[i];
// get namespace prefix
Expand Down Expand Up @@ -1398,7 +1398,7 @@ function serializeToString(node,buf,isHTML,nodeFilter,visibleNamespaces){
var len = attrs.length;
var child = node.firstChild;
var nodeName = node.tagName;

isHTML = NAMESPACE.isHTML(node.namespaceURI) || isHTML

var prefixedNodeName = nodeName
Expand Down Expand Up @@ -1457,14 +1457,14 @@ function serializeToString(node,buf,isHTML,nodeFilter,visibleNamespaces){
serializeToString(attr,buf,isHTML,nodeFilter,visibleNamespaces);
}

// add namespace for current node
// add namespace for current node
if (nodeName === prefixedNodeName && needNamespaceDefine(node, isHTML, visibleNamespaces)) {
var prefix = node.prefix||'';
var uri = node.namespaceURI;
addSerializedAttribute(buf, prefix ? 'xmlns:' + prefix : "xmlns", uri);
visibleNamespaces.push({ prefix: prefix, namespace:uri });
}

if(child || isHTML && !/^(?:meta|link|img|br|hr|input)$/i.test(nodeName)){
buf.push('>');
//if is cdata child node
Expand Down Expand Up @@ -1677,7 +1677,7 @@ try{
}
}
})

function getTextContent(node){
switch(node.nodeType){
case ELEMENT_NODE:
Expand Down

0 comments on commit 04c9f26

Please sign in to comment.