if(currentTag.attr('wlxml-tag'))
return;
- var meta = {};
+ var meta = {}, others = {};
for(var i = 0; i < this.attributes.length; i++) {
var attr = this.attributes[i];
if(attr.name.substr(0, 5) === 'meta-')
meta[attr.name.substr(5)] = attr.value;
+ else if(attr.name !== 'class')
+ others[attr.name] = attr.value;
}
var element = documentElement.DocumentNodeElement.create({
tag: currentTag.prop('tagName').toLowerCase(),
klass: currentTag.attr('class'),
- meta: meta
+ meta: meta,
+ others: others
});
element.dom().append(currentTag.contents());
expect(input.isEqualNode(output)).to.be.true;
});
+ it('keeps arbitrary node attributes intact', function() {
+ var xmlIn = '<section a="1" xmlns:dcterms="http://purl.org/dc/terms/"></section>',
+ $xmlOut = $(canvas.fromXML(xmlIn).toXML());
+
+ expect($xmlOut.attr('a')).to.equal('1');
+ expect($xmlOut.attr('xmlns:dcterms')).to.equal('http://purl.org/dc/terms/');
+
+ });
+
describe('formatting output xml', function() {
/*it('keeps white spaces at the edges of input xml', function() {
var xmlIn = ' <section></section> ',
dom.attr('wlxml-meta-'+key, params.meta[key]);
});
}
+ dom.data('other-attrs', params.others);
return dom;
},
meta.forEach(function(attr) {
node.attr('meta-' + attr.name, attr.value);
});
+ _.keys(this.data('other-attrs') || {}).forEach(function(key) {
+ node.attr(key, this.data('other-attrs')[key]);
+ }, this);
if(this.data('orig-before') !== undefined) {
toret.append(document.createTextNode(this.data('orig-before')));