Comparing version 0.7.2 to 0.8.0
@@ -12,4 +12,4 @@ 'use strict'; | ||
this.parent = null | ||
this.attrs = attrs || {} | ||
this.children = [] | ||
this.setAttrs(attrs) | ||
} | ||
@@ -85,2 +85,8 @@ | ||
Element.prototype.setAttrs = function(attrs) { | ||
this.attrs = {} | ||
Object.keys(attrs || {}).forEach(function(key) { | ||
this.attrs[key] = attrs[key] | ||
}, this) | ||
} | ||
@@ -267,7 +273,3 @@ /** | ||
Element.prototype.clone = function() { | ||
var clone = this._getElement(this.name, {}) | ||
for (var k in this.attrs) { | ||
if (this.attrs.hasOwnProperty(k)) | ||
clone.attrs[k] = this.attrs[k] | ||
} | ||
var clone = this._getElement(this.name, this.attrs) | ||
for (var i = 0; i < this.children.length; i++) { | ||
@@ -314,3 +316,3 @@ var child = this.children[i] | ||
children: this.children.map(function(child) { | ||
return child && child.toJSON ? child.toJSON() : child; | ||
return child && child.toJSON ? child.toJSON() : child | ||
}) | ||
@@ -317,0 +319,0 @@ } |
@@ -125,4 +125,4 @@ (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
this.parent = null | ||
this.attrs = attrs || {} | ||
this.children = [] | ||
this.setAttrs(attrs) | ||
} | ||
@@ -198,2 +198,8 @@ | ||
Element.prototype.setAttrs = function(attrs) { | ||
this.attrs = {} | ||
Object.keys(attrs || {}).forEach(function(key) { | ||
this.attrs[key] = attrs[key] | ||
}, this) | ||
} | ||
@@ -380,7 +386,3 @@ /** | ||
Element.prototype.clone = function() { | ||
var clone = this._getElement(this.name, {}) | ||
for (var k in this.attrs) { | ||
if (this.attrs.hasOwnProperty(k)) | ||
clone.attrs[k] = this.attrs[k] | ||
} | ||
var clone = this._getElement(this.name, this.attrs) | ||
for (var i = 0; i < this.children.length; i++) { | ||
@@ -427,3 +429,3 @@ var child = this.children[i] | ||
children: this.children.map(function(child) { | ||
return child && child.toJSON ? child.toJSON() : child; | ||
return child && child.toJSON ? child.toJSON() : child | ||
}) | ||
@@ -815,7 +817,8 @@ } | ||
return s. | ||
replace(/\&/g, '&'). | ||
replace(/\</g, '<'). | ||
replace(/\>/g, '>'). | ||
replace(/\"/g, '"'). | ||
replace(/\'/g, '\'') | ||
replace(/\&(amp|#38);/g, '&'). | ||
replace(/\&(lt|#60);/g, '<'). | ||
replace(/\&(gt|#62);/g, '>'). | ||
replace(/\&(quot|#34);/g, '"'). | ||
replace(/\&(apos|#39);/g, '\''). | ||
replace(/\&(nbsp|#160);/g, '\n') | ||
} | ||
@@ -883,4 +886,6 @@ | ||
throw er; // Unhandled 'error' event | ||
} else { | ||
throw TypeError('Uncaught, unspecified "error" event.'); | ||
} | ||
throw TypeError('Uncaught, unspecified "error" event.'); | ||
return false; | ||
} | ||
@@ -970,6 +975,3 @@ } | ||
this._events[type].length); | ||
if (typeof console.trace === 'function') { | ||
// not supported in IE 10 | ||
console.trace(); | ||
} | ||
console.trace(); | ||
} | ||
@@ -1201,7 +1203,4 @@ } | ||
process.on = noop; | ||
process.addListener = noop; | ||
process.once = noop; | ||
process.off = noop; | ||
process.removeListener = noop; | ||
process.removeAllListeners = noop; | ||
process.emit = noop; | ||
@@ -1815,3 +1814,3 @@ | ||
}).call(this,require("JkpR2F"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) | ||
},{"./support/isBuffer":10,"JkpR2F":9,"inherits":8}]},{},[3]) | ||
}).call(this,require("/Users/lloyd/MyStuff/code/node-xmpp/ltx/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) | ||
},{"./support/isBuffer":10,"/Users/lloyd/MyStuff/code/node-xmpp/ltx/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":9,"inherits":8}]},{},[3]) |
{ | ||
"name": "ltx", | ||
"version": "0.7.2", | ||
"version": "0.8.0", | ||
"main": "./lib/index", | ||
@@ -5,0 +5,0 @@ "browser": "./lib/index-browserify", |
@@ -8,2 +8,13 @@ 'use strict'; | ||
vows.describe('ltx').addBatch({ | ||
'new element': { | ||
'doesn\'t reference original attrs object': function() { | ||
var o = { foo: 'bar' } | ||
var e = new ltx.Element('e', o) | ||
assert.notEqual(e.attrs, o) | ||
e.attrs.bar = 'foo' | ||
assert.equal(o.bar, undefined) | ||
o.foobar = 'barfoo' | ||
assert.equal(e.attrs.foobar, undefined) | ||
} | ||
}, | ||
'serialization': { | ||
@@ -158,3 +169,3 @@ 'serialize an element': function() { | ||
assert.equal(clone.getChildText('description'), 'foobar') | ||
} | ||
}, | ||
}, | ||
@@ -170,3 +181,3 @@ 'children': { | ||
.root() | ||
var children = el.children | ||
@@ -173,0 +184,0 @@ assert.equal(children.length, 4) |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
103217
3077
28