[Pkg-javascript-commits] [ltx] 412/469: better configurability for parser and Parser
Jonas Smedegaard
dr at jones.dk
Wed Aug 31 13:03:33 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 d7c28bf68291a0b5012bd485e9a0c1d6b357f2b1
Author: Sonny Piers <sonny at fastmail.net>
Date: Tue Nov 24 13:53:37 2015 +0100
better configurability for parser and Parser
---
.gitignore | 4 +-
.travis.yml | 8 ++--
index.js | 20 ++++-----
lib/Element.js | 67 +++++-----------------------
lib/Parser.js | 8 +++-
lib/createElement.js | 14 ++++++
lib/equal.js | 48 ++++++++++++++++++++
lib/parse.js | 8 +++-
package.json | 4 +-
test/createElement-test.js | 20 +++++++++
test/element-test.js | 106 +++++++++++++++++++++++++++------------------
test/equality-test.js | 64 ++++++++++++++-------------
12 files changed, 220 insertions(+), 151 deletions(-)
diff --git a/.gitignore b/.gitignore
index e4adf3b..c1a99ba 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,8 +1,6 @@
-node_modules/
-
!.editorconfig
!.gitignore
!.npmignore
!.travis.yml
-/ltx.js
+bundle.js
diff --git a/.travis.yml b/.travis.yml
index 7653c21..36d9d92 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -8,10 +8,8 @@ env:
node_js:
- '0.10'
- '0.12'
- - '4.0'
- - '4.1'
- - '4.2'
- - '5.0'
+ - '4'
+ - '5'
- 'stable'
addons:
@@ -22,5 +20,5 @@ addons:
- g++-4.8
- gcc-4.8
-before_script:
+before_install:
- npm install -g browserify standard
diff --git a/index.js b/index.js
index 963b22f..011bd7f 100644
--- a/index.js
+++ b/index.js
@@ -4,22 +4,20 @@ var parse = require('./lib/parse')
var Parser = require('./lib/Parser')
var escape = require('./lib/escape')
var Element = require('./lib/Element')
+var equal = require('./lib/equal')
+var createElement = require('./lib/createElement')
-/**
- * Element
- */
exports.Element = Element
-exports.equals = Element.equals
-exports.createElement = Element.createElement
-/**
- * Helpers
- */
+exports.equal = equal.equal
+exports.nameEqual = equal.name
+exports.attrsEqual = equal.attrs
+exports.childrenEqual = equal.children
+
+exports.createElement = createElement
+
exports.escapeXML = escape.escapeXML
exports.escapeXMLText = escape.escapeXMLText
-/**
- * parser interface
- */
exports.Parser = Parser
exports.parse = parse
diff --git a/lib/Element.js b/lib/Element.js
index 1559f86..9b76301 100644
--- a/lib/Element.js
+++ b/lib/Element.js
@@ -4,6 +4,12 @@ var escape = require('./escape')
var escapeXML = escape.escapeXML
var escapeXMLText = escape.escapeXMLText
+var equality = require('./equal')
+var equal = equality.equal
+var nameEqual = equality.name
+var attrsEqual = equality.attrs
+var childrenEqual = equality.children
+
/**
* This cheap replica of DOM/Builder puts me to shame :-)
*
@@ -380,72 +386,19 @@ Element.prototype.write = function (writer) {
}
Element.prototype.nameEquals = function (el) {
- return this.name === el.name
+ return nameEqual(this, el)
}
Element.prototype.attrsEquals = function (el) {
- var attrs = this.attrs
- var keys = Object.keys(attrs)
- var length = keys.length
- if (length !== Object.keys(el.attrs).length) return false
- for (var i = 0, l = length; i < l; i++) {
- var key = keys[i]
- var value = attrs[key]
- if (value == null || el.attrs[key] == null) { // === null || undefined
- if (value !== el.attrs[key]) return false
- }
- else if (value.toString() !== el.attrs[key].toString()) return false
- }
- return true
+ return attrsEqual(this, el)
}
Element.prototype.childrenEquals = function (el) {
- var children = this.children
- var length = children.length
- if (length !== el.children.length) return false
- for (var i = 0, l = length; i < l; i++) {
- var child = children[i]
- if (typeof child === 'string') {
- if (child !== el.children[i]) return false
- } else {
- if (!child.equals(el.children[i])) return false
- }
- }
- return true
+ return childrenEqual(this, el)
}
Element.prototype.equals = function (el) {
- if (!this.nameEquals(el)) return false
- if (!this.attrsEquals(el)) return false
- if (!this.childrenEquals(el)) return false
- return true
-}
-
-Element.createElement = function (name, attrs /*, child1, child2, ...*/) {
- var el = new Element(name, attrs)
-
- var children = Array.prototype.slice.call(arguments, 2)
-
- children.forEach(function (child) {
- el.cnode(child)
- })
- return el
-}
-
-Element.nameEqual = function (a, b) {
- return a.nameEquals(b)
-}
-
-Element.attrsEqual = function (a, b) {
- return a.attrsEquals(b)
-}
-
-Element.childrenEqual = function (a, b) {
- return a.childrenEquals(b)
-}
-
-Element.equal = function (a, b) {
- return a.equals(b)
+ return equal(this, el)
}
module.exports = Element
diff --git a/lib/Parser.js b/lib/Parser.js
index e9a0f78..cb00f0b 100644
--- a/lib/Parser.js
+++ b/lib/Parser.js
@@ -8,8 +8,8 @@ var LtxParser = require('./parsers/ltx')
var Parser = function (options) {
EventEmitter.call(this)
- var ParserInterface = this.Parser = (options && options.Parser) || LtxParser
- var ElementInterface = this.Element = (options && options.Element) || Element
+ var ParserInterface = this.Parser = (options && options.Parser) || this.DefaultParser
+ var ElementInterface = this.Element = (options && options.Element) || this.DefaultElement
this.parser = new ParserInterface()
@@ -48,6 +48,10 @@ var Parser = function (options) {
inherits(Parser, EventEmitter)
+Parser.prototype.DefaultParser = LtxParser
+
+Parser.prototype.DefaultElement = Element
+
Parser.prototype.write = function (data) {
this.parser.write(data)
}
diff --git a/lib/createElement.js b/lib/createElement.js
new file mode 100644
index 0000000..44abdad
--- /dev/null
+++ b/lib/createElement.js
@@ -0,0 +1,14 @@
+'use strict'
+
+var Element = require('./Element')
+
+module.exports = function createElement (name, attrs /*, child1, child2, ...*/) {
+ var el = new Element(name, attrs)
+
+ var children = Array.prototype.slice.call(arguments, 2)
+
+ children.forEach(function (child) {
+ el.cnode(child)
+ })
+ return el
+}
diff --git a/lib/equal.js b/lib/equal.js
new file mode 100644
index 0000000..4ec4b9d
--- /dev/null
+++ b/lib/equal.js
@@ -0,0 +1,48 @@
+'use strict'
+
+function nameEqual (a, b) {
+ return a.name === b.name
+}
+
+function attrsEqual (a, b) {
+ var attrs = a.attrs
+ var keys = Object.keys(attrs)
+ var length = keys.length
+ if (length !== Object.keys(b.attrs).length) return false
+ for (var i = 0, l = length; i < l; i++) {
+ var key = keys[i]
+ var value = attrs[key]
+ if (value == null || b.attrs[key] == null) { // === null || undefined
+ if (value !== b.attrs[key]) return false
+ }
+ else if (value.toString() !== b.attrs[key].toString()) return false
+ }
+ return true
+}
+
+function childrenEqual (a, b) {
+ var children = a.children
+ var length = children.length
+ if (length !== b.children.length) return false
+ for (var i = 0, l = length; i < l; i++) {
+ var child = children[i]
+ if (typeof child === 'string') {
+ if (child !== b.children[i]) return false
+ } else {
+ if (!child.equals(b.children[i])) return false
+ }
+ }
+ return true
+}
+
+function equal (a, b) {
+ if (!nameEqual(a, b)) return false
+ if (!attrsEqual(a, b)) return false
+ if (!childrenEqual(a, b)) return false
+ return true
+}
+
+module.exports.name = nameEqual
+module.exports.attrs = attrsEqual
+module.exports.children = childrenEqual
+module.exports.equal = equal
diff --git a/lib/parse.js b/lib/parse.js
index 216ed2a..1aab87a 100644
--- a/lib/parse.js
+++ b/lib/parse.js
@@ -3,7 +3,13 @@
var Parser = require('./Parser')
module.exports = function parse (data, options) {
- var p = new Parser(options)
+ var p
+ if (typeof options === 'function') {
+ p = new options() // eslint-disable-line
+ } else {
+ p = new Parser(options)
+ }
+
var result = null
var error = null
diff --git a/package.json b/package.json
index f8e09a4..812eb71 100644
--- a/package.json
+++ b/package.json
@@ -30,10 +30,10 @@
"engine": "node",
"scripts": {
"preversion": "npm test",
- "webify": "browserify -s ltx index.js -o ltx.js",
+ "bundle": "browserify -s ltx index.js -o bundle.js",
"unit": "vows --spec",
"lint": "standard",
- "test": "npm run unit && npm run lint && npm run webify"
+ "test": "npm run unit && npm run lint && npm run bundle"
},
"dependencies": {
"inherits": "^2.0.1"
diff --git a/test/createElement-test.js b/test/createElement-test.js
new file mode 100644
index 0000000..af5d02f
--- /dev/null
+++ b/test/createElement-test.js
@@ -0,0 +1,20 @@
+'use strict'
+
+var vows = require('vows')
+var assert = require('assert')
+var ltx = require('..')
+var Element = ltx.Element
+var createElement = ltx.createElement
+
+vows.describe('createElement').addBatch({
+ 'create a new element and set children': function () {
+ var c = new Element('bar')
+ var e = createElement('foo', {'foo': 'bar'}, 'foo', c)
+ assert(e instanceof Element)
+ assert(e.is('foo'))
+ assert.equal(e.attrs.foo, 'bar')
+ assert.equal(e.children.length, 2)
+ assert.equal(e.children[0], 'foo')
+ assert.equal(e.children[1], c)
+ }
+}).export(module)
diff --git a/test/element-test.js b/test/element-test.js
index d7cb135..6bef848 100644
--- a/test/element-test.js
+++ b/test/element-test.js
@@ -3,13 +3,13 @@
var vows = require('vows')
var assert = require('assert')
var ltx = require('..')
-var Element = require('../lib/Element')
+var Element = ltx.Element
vows.describe('Element').addBatch({
'new element': {
"doesn't reference original attrs object": function () {
var o = { foo: 'bar' }
- var e = new ltx.Element('e', o)
+ var e = new Element('e', o)
assert.notEqual(e.attrs, o)
e.attrs.bar = 'foo'
assert.equal(o.bar, undefined)
@@ -18,84 +18,72 @@ vows.describe('Element').addBatch({
},
'set xmlns attribute if a string is passed as second argument': function () {
var ns = 'xmlns:test'
- var e = new ltx.Element('e', ns)
+ var e = new Element('e', ns)
assert.equal(e.attrs.xmlns, ns)
assert.equal(e.getAttr('xmlns'), ns)
}
},
- 'createElement': {
- 'create a new element and set children': function () {
- var c = new ltx.Element('bar')
- var e = ltx.createElement('foo', {'foo': 'bar'}, 'foo', c)
- assert(e instanceof Element)
- assert(e.is('foo'))
- assert.equal(e.attrs.foo, 'bar')
- assert.equal(e.children.length, 2)
- assert.equal(e.children[0], 'foo')
- assert.equal(e.children[1], c)
- }
- },
'serialization': {
'serialize an element': function () {
- var e = new ltx.Element('e')
+ var e = new Element('e')
assert.equal(e.toString(), '<e/>')
},
'serialize an element with attributes': function () {
- var e = new ltx.Element('e', { a1: 'foo' })
+ var e = new Element('e', { a1: 'foo' })
assert.equal(e.toString(), '<e a1="foo"/>')
},
'serialize an element with attributes to entities': function () {
- var e = new ltx.Element('e', { a1: '"well"' })
+ var e = new Element('e', { a1: '"well"' })
assert.equal(e.toString(), '<e a1=""well""/>')
},
'serialize an element with text': function () {
- var e = new ltx.Element('e').t('bar').root()
+ var e = new Element('e').t('bar').root()
assert.equal(e.toString(), '<e>bar</e>')
},
'serialize an element with text to entities': function () {
- var e = new ltx.Element('e').t('1 < 2').root()
+ var e = new Element('e').t('1 < 2').root()
assert.equal(e.toString(), '<e>1 < 2</e>')
},
'serialize an element with a number attribute': function () {
- var e = new ltx.Element('e', { a: 23 })
+ var e = new Element('e', { a: 23 })
assert.equal(e.toString(), '<e a="23"/>')
},
'serialize an element with number contents': function () {
- var e = new ltx.Element('e')
+ var e = new Element('e')
e.c('foo').t(23)
e.c('bar').t(0)
assert.equal(e.toString(), '<e><foo>23</foo><bar>0</bar></e>')
},
'serialize with undefined attribute': function () {
- var e = new ltx.Element('e', { foo: undefined })
+ var e = new Element('e', { foo: undefined })
assert.equal(e.toString(), '<e/>')
},
'serialize with null attribute': function () {
- var e = new ltx.Element('e', { foo: null })
+ var e = new Element('e', { foo: null })
assert.equal(e.toString(), '<e/>')
},
'serialize with number attribute': function () {
- var e = new ltx.Element('e', { foo: 23, bar: 0 })
+ var e = new Element('e', { foo: 23, bar: 0 })
var s = e.toString()
assert.ok(s.match(/foo="23"/))
assert.ok(s.match(/bar="0"/))
},
'serialize with undefined child': function () {
- var e = new ltx.Element('e')
+ var e = new Element('e')
e.children = [undefined]
assert.equal(e.toString(), '<e></e>')
},
'serialize with null child': function () {
- var e = new ltx.Element('e')
+ var e = new Element('e')
e.children = [null]
assert.equal(e.toString(), '<e></e>')
},
'serialize with integer text': function () {
- var e = new ltx.Element('e').t(1000)
+ var e = new Element('e').t(1000)
assert.equal(e.getText(), 1000)
},
'serialize to json': function () {
- var e = new ltx.Element('e', { foo: 23, bar: 0, nil: null }).c('f').t(1000).up()
+ var e = new Element('e', { foo: 23, bar: 0, nil: null }).c('f').t(1000).up()
assert.deepEqual(e.toJSON(), {
name: 'e',
attrs: { foo: 23, bar: 0, nil: null },
@@ -107,13 +95,13 @@ vows.describe('Element').addBatch({
},
'remove': {
'by element': function () {
- var el = new ltx.Element('e').c('c').c('x').up().up().c('c2').up().c('c').up()
+ var el = new Element('e').c('c').c('x').up().up().c('c2').up().c('c').up()
el.remove(el.getChild('c'))
assert.equal(el.getChildren('c').length, 1)
assert.equal(el.getChildren('c2').length, 1)
},
'by name': function () {
- var el = new ltx.Element('e').c('c').up().c('c2').up().c('c').up()
+ var el = new Element('e').c('c').up().c('c2').up().c('c').up()
el.remove('c')
assert.equal(el.getChildren('c').length, 0)
assert.equal(el.getChildren('c2').length, 1)
@@ -135,9 +123,45 @@ vows.describe('Element').addBatch({
assert.equal(el.getAttr('title', 'http://site.tld/job'), 'hacker')
}
},
+ // extensively tested in equality-test.js
+ 'equality': {
+ 'name': function () {
+ var a = new Element('foo')
+ var b = new Element('foo')
+ assert.equal(a.nameEquals(a), true)
+ assert.equal(a.nameEquals(b), true)
+ assert.equal(b.nameEquals(a), true)
+
+ b = new Element('b')
+ assert.equal(a.nameEquals(b), false)
+ assert.equal(b.nameEquals(a), false)
+ },
+ 'attrs': function () {
+ var a = new Element('foo', {foo: 'bar'})
+ var b = new Element('foo', {foo: 'bar'})
+ assert.equal(a.attrsEquals(a), true)
+ assert.equal(a.attrsEquals(b), true)
+ assert.equal(b.attrsEquals(a), true)
+
+ b = new Element('foo', {bar: 'foo'})
+ assert.equal(a.attrsEquals(b), false)
+ assert.equal(b.attrsEquals(a), false)
+ },
+ 'children': function () {
+ var a = new Element('foo').c('foo').root()
+ var b = new Element('foo').c('foo').root()
+ assert.equal(a.childrenEquals(a), true)
+ assert.equal(a.childrenEquals(b), true)
+ assert.equal(b.childrenEquals(a), true)
+
+ b = new Element('foo').c('bar').root()
+ assert.equal(a.childrenEquals(b), false)
+ assert.equal(b.childrenEquals(a), false)
+ }
+ },
'clone': {
'clones': function () {
- var orig = new ltx.Element('msg', { type: 'get' }).c('content').t('foo').root()
+ var orig = new Element('msg', { type: 'get' }).c('content').t('foo').root()
var clone = orig.clone()
assert.equal(clone.name, orig.name)
assert.equal(clone.attrs.type, orig.attrs.type)
@@ -149,7 +173,7 @@ vows.describe('Element').addBatch({
assert.equal(clone.getChild('content').up(), clone)
},
'mod attr': function () {
- var orig = new ltx.Element('msg', { type: 'get' })
+ var orig = new Element('msg', { type: 'get' })
var clone = orig.clone()
clone.attrs.type += '-result'
@@ -157,7 +181,7 @@ vows.describe('Element').addBatch({
assert.equal(clone.attrs.type, 'get-result')
},
'rm attr': function () {
- var orig = new ltx.Element('msg', { from: 'me' })
+ var orig = new Element('msg', { from: 'me' })
var clone = orig.clone()
delete clone.attrs.from
clone.attrs.to = 'you'
@@ -168,7 +192,7 @@ vows.describe('Element').addBatch({
assert.equal(clone.attrs.to, 'you')
},
'mod child': function () {
- var orig = new ltx.Element('msg', { type: 'get' }).c('content').t('foo').root()
+ var orig = new Element('msg', { type: 'get' }).c('content').t('foo').root()
var clone = orig.clone()
clone.getChild('content').t('bar').name = 'description'
@@ -180,7 +204,7 @@ vows.describe('Element').addBatch({
},
'children': {
'getChildren': function () {
- var el = new ltx.Element('a')
+ var el = new Element('a')
.c('b')
.c('b2').up().up()
.t('foo')
@@ -196,7 +220,7 @@ vows.describe('Element').addBatch({
assert.equal(children[3], 'bar')
},
'getChildElements': function () {
- var el = new ltx.Element('a')
+ var el = new Element('a')
.c('b')
.c('b2').up().up()
.t('foo')
@@ -213,7 +237,7 @@ vows.describe('Element').addBatch({
'recursive': {
'getChildrenByAttr': function () {
- var el = new ltx.Element('a')
+ var el = new Element('a')
.c('b')
.c('c', {myProperty: 'x'}).t('bar').up().up().up()
.c('d', {id: 'x'})
@@ -224,7 +248,7 @@ vows.describe('Element').addBatch({
assert.equal(results[1].toString(), '<e myProperty="x"/>')
},
'getChildByAttr': function () {
- var el = new ltx.Element('a')
+ var el = new Element('a')
.c('b')
.c('c', {id: 'x'})
.t('bar').root()
@@ -252,8 +276,8 @@ vows.describe('Element').addBatch({
'issue-37: Element instanceof Fails': {
'instanceof': function () {
- var el = new ltx.Element('root').c('children')
- assert.ok(el instanceof ltx.Element)
+ var el = new Element('root').c('children')
+ assert.ok(el instanceof Element)
}
}
}).export(module)
diff --git a/test/equality-test.js b/test/equality-test.js
index 7abe67b..5055296 100644
--- a/test/equality-test.js
+++ b/test/equality-test.js
@@ -2,119 +2,125 @@
var vows = require('vows')
var assert = require('assert')
-var Element = require('../lib/Element')
+var ltx = require('../index')
+var Element = ltx.Element
+var nameEqual = ltx.nameEqual
+var attrsEqual = ltx.attrsEqual
+var childrenEqual = ltx.childrenEqual
+var equal = ltx.equal
vows.describe('equality').addBatch({
- 'nameEquals': {
+ 'nameEqual': {
'it returns true if elements name are equal': function () {
var a = new Element('foo')
var b = new Element('foo')
- assert.equal(a.nameEquals(b), true)
+ assert.equal(nameEqual(a, b), true)
var c = new Element('foo:bar')
var d = new Element('foo:bar')
- assert.equal(c.nameEquals(d), true)
+ assert.equal(nameEqual(c, d), true)
},
'it returns false if elements name differ': function () {
var a = new Element('foo')
var b = new Element('bar')
- assert.equal(a.nameEquals(b), false)
+ assert.equal(nameEqual(a, b), false)
var c = new Element('foo:bar')
var d = new Element('bar:bar')
- assert.equal(c.nameEquals(d), false)
+ assert.equal(nameEqual(c, d), false)
var e = new Element('foo:bar')
var f = new Element('foo:foo')
- assert.equal(e.nameEquals(f), false)
+ assert.equal(nameEqual(e, f), false)
}
},
- 'attrsEquals': {
+ 'attrsEqual': {
'it returns true if elements attributes are equal': function () {
var a = new Element('foo', {a: 'b', b: 'c'})
var b = new Element('foo', {a: 'b', b: 'c'})
- assert.equal(a.attrsEquals(b), true)
+ assert.equal(attrsEqual(a, b), true)
var c = new Element('foo', {a: 'b', b: 'c'})
var d = new Element('foo', {b: 'c', a: 'b'})
- assert.equal(c.attrsEquals(d), true)
+ assert.equal(attrsEqual(c, d), true)
},
'it returns true if elements attributes are serialized equaly': function () {
var a = new Element('foo', {foo: 'false'})
var b = new Element('foo', {foo: false})
- assert.equal(a.attrsEquals(b), true)
+ assert.equal(attrsEqual(a, b), true)
var c = new Element('foo', {foo: '0'})
var d = new Element('foo', {foo: 0})
- assert.equal(c.attrsEquals(d), true)
+ assert.equal(attrsEqual(c, d), true)
var foo = {toString: function () { return 'hello' }}
var e = new Element('foo', {foo: foo})
var f = new Element('foo', {foo: 'hello'})
- assert.equal(e.attrsEquals(f), true)
+ assert.equal(attrsEqual(e, f), true)
},
'it returns false if elements attributes differ': function () {
var a = new Element('foo', {a: 'b'})
var b = new Element('foo')
- assert.equal(a.attrsEquals(b), false)
+ assert.equal(attrsEqual(a, b), false)
var c = new Element('foo')
var d = new Element('foo', {a: 'b'})
- assert.equal(c.attrsEquals(d), false)
+ assert.equal(attrsEqual(c, d), false)
var e = new Element('foo', {b: 'a'})
var f = new Element('foo', {a: 'b'})
- assert.equal(e.attrsEquals(f), false)
+ assert.equal(attrsEqual(e, f), false)
var g = new Element('foo', {foo: 'bar'})
var h = new Element('foo', {bar: 'bar'})
- assert.equal(g.attrsEquals(h), false)
+ assert.equal(attrsEqual(g, h), false)
}
},
- 'childrenEquals': {
+ 'childrenEqual': {
'it returns true if elements children are equal': function () {
var a = new Element('foo').c('bar').up().c('foo').root()
- assert.equal(a.childrenEquals(a), true)
+ assert.equal(childrenEqual(a, a), true)
+
var b = new Element('foo').c('bar').up().c('foo').root()
- assert.equal(a.childrenEquals(b), true)
+ assert.equal(childrenEqual(a, b), true)
},
'it returns false if elements children name differ': function () {
var a = new Element('foo').c('bar').root()
var b = new Element('foo').c('foo').root()
- assert.equal(a.childrenEquals(b), false)
+ assert.equal(childrenEqual(a, b), false)
},
'it returns false if elements children attrs differ': function () {
var a = new Element('foo').c('foo', {foo: 'bar'}).root()
var b = new Element('foo').c('foo', {bar: 'foo'}).root()
- assert.equal(a.childrenEquals(b), false)
+ assert.equal(childrenEqual(a, b), false)
},
'it returns false if elements children order differ': function () {
var a = new Element('foo').c('foo').up().c('bar').root()
var b = new Element('foo').c('bar').up().c('foo').root()
- assert.equal(a.childrenEquals(b), false)
+ assert.equal(childrenEqual(a, b), false)
}
},
- 'equals': {
+ 'equal': {
'it returns true if elements are equal': function () {
var a = new Element('a', {foo: 'bar'}).c('hello').root()
- assert.equal(a.equals(a), true)
+ assert.equal(equal(a, a), true)
var b = new Element('a', {foo: 'bar'}).c('hello').root()
- assert.equal(a.equals(b), true)
+ assert.equal(equal(a, b), true)
},
'it returns false if elements name differ': function () {
var a = new Element('foo')
var b = new Element('bar')
- assert.equal(a.equals(b), false)
+ assert.equal(equal(a, b), false)
},
'it returns false if elements attrs differ': function () {
var a = new Element('foo', {foo: 'bar'})
var b = new Element('foo')
- assert.equal(a.equals(b), false)
+ assert.equal(equal(a, b), false)
},
'it returns false if elements children differ': function () {
var a = new Element('foo').c('foo').root()
var b = new Element('foo').c('bar').root()
- assert.equal(a.equals(b), false)
+ assert.equal(equal(a, b), false)
}
}
}).export(module)
--
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