[Pkg-javascript-commits] [ltx] 321/469: Merge branch 'dom' of git://github.com/node-xmpp/ltx

Jonas Smedegaard dr at jones.dk
Wed Aug 31 13:03:21 UTC 2016


This is an automated email from the git hooks/post-receive script.

js pushed a commit to branch master
in repository ltx.

commit f418cb03f74f625b0464ee1073c504726db2477d
Merge: 745b26e 515cb64
Author: ▟ ▖▟ ▖ <dodo.the.last at gmail.com>
Date:   Wed Feb 19 22:36:27 2014 +0100

    Merge branch 'dom' of git://github.com/node-xmpp/ltx
    
    Conflicts:
    	lib/index.js
    	lib/parse.js
    	test/parse-test.js

 lib/dom-element.js       | 93 ++++++++++++++++++++++++++++++++++++++++++++++++
 lib/index.js             | 10 +++---
 lib/parse.js             | 19 ++++++----
 test/dom-element-test.js | 38 ++++++++++++++++++++
 4 files changed, 148 insertions(+), 12 deletions(-)

diff --cc lib/dom-element.js
index 0000000,2e8bb78..a5a794d
mode 000000,100644..100644
--- a/lib/dom-element.js
+++ b/lib/dom-element.js
@@@ -1,0 -1,91 +1,93 @@@
++'use strict';
++
+ var util = require('util')
+   , Element = require('./element').Element
+ 
+ function DOMElement(name, attrs) {
+     Element.call(this, name, attrs)
+ 
+     this.nodeType = 1
+     this.nodeName = this.localName
+ }
+ 
+ util.inherits(DOMElement, Element)
+ 
+ Object.defineProperty(DOMElement.prototype, 'localName', {
+     get: function () {
+         return this.getName()
+     }
+ })
+ 
+ Object.defineProperty(DOMElement.prototype, 'namespaceURI', {
+     get: function () {
+         return this.getNS()
+     }
+ })
+ 
+ Object.defineProperty(DOMElement.prototype, 'parentNode', {
+     get: function () {
+         return this.parent
+     }
+ })
+ 
+ Object.defineProperty(DOMElement.prototype, 'childNodes', {
+     get: function () {
+         return this.children
+     }
+ })
+ 
+ Object.defineProperty(DOMElement.prototype, 'textContent', {
+     get: function () {
+         return this.getText()
+     },
+     set: function (value) {
+         this.children.push(value)
+     }
+ })
+ 
+ DOMElement.prototype.getElementsByTagName = function (name) {
+     var res = this.getChildren(name)
+     return this.getChildren(name)
+ }
+ 
+ DOMElement.prototype.getAttribute = function (name) {
+     return this.getAttr(name)
+ }
+ 
+ DOMElement.prototype.setAttribute = function (name, value) {
+     this.attr(name, value)
+ }
+ 
+ DOMElement.prototype.getAttributeNS = function (ns, name) {
+     if (ns === 'http://www.w3.org/XML/1998/namespace') {
+         return this.getAttr(['xml', name].join(':'))
+     }
+     return this.getAttr(name, ns)
+ }
+ 
+ DOMElement.prototype.setAttributeNS = function (ns, name, value) {
+     var prefix
+     if (ns === 'http://www.w3.org/XML/1998/namespace') {
+         prefix = 'xml'
+     } else {
+         var nss = this.getXmlns()
+         prefix = nss[ns] || ''
+     }
+     if (prefix) {
+         this.attr([prefix, name].join(':'), value)
+     }
+ }
+ 
+ DOMElement.prototype.removeAttribute = function (name) {
+     this.attr(name, null)
+ }
+ 
+ DOMElement.prototype.appendChild = function (el) {
+     this.cnode(el)
+ }
+ 
+ DOMElement.prototype.removeChild = function (el) {
+     this.remove(el)
+ }
+ 
+ module.exports = DOMElement
diff --cc lib/index.js
index b41e7d0,a67fea8..e208cbe
--- a/lib/index.js
+++ b/lib/index.js
@@@ -1,16 -1,15 +1,16 @@@
 -var element = require('./dom-element')
 -  , parse = require('./parse')
 +'use strict';
 +
- var element = require('./element')
-   , parse = require('./parse')
++var parse = require('./parse')
  
  /**
   * The only (relevant) data structure
   */
- exports.Element = element.Element
 -exports.Element = element
++exports.Element = require('./dom-element')
+ 
  /**
   * Helper
   */
--exports.escapeXml = element.escapeXml
++exports.escapeXml = require('./element').escapeXml
  
  /**
   * DOM parser interface
diff --cc lib/parse.js
index 915bfef,d940ff6..1e2e19d
--- a/lib/parse.js
+++ b/lib/parse.js
@@@ -1,9 -1,9 +1,11 @@@
 +'use strict';
 +
  var events = require('events')
    , util = require('util')
+   , DOMElement = require('./dom-element')
+ 
 -exports.availableSaxParsers = []
  
 +exports.availableSaxParsers = []
  exports.bestSaxParser = null
  
  var saxParsers = [
@@@ -52,7 -51,9 +52,9 @@@ exports.Parser = function(saxParser) 
          }
      })
      this.parser.addListener('endElement', function(name) {
-         if (el && (name === el.name)) {
+         if (!el) {
+             /* Err */
 -        } else if (el && (name === el.name)) {
++        } else if (name === el.name) {
              if (el.parent) {
                  el = el.parent
              } else if (!self.tree) {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/ltx.git



More information about the Pkg-javascript-commits mailing list