Skip to content

Commit

Permalink
Merge pull request #66 from karfau/56/consistent-line-separators
Browse files Browse the repository at this point in the history
fix: Convert all line separators to LF
  • Loading branch information
brodybits committed Jun 28, 2020
2 parents 5883af5 + 8a31e94 commit 0ade062
Show file tree
Hide file tree
Showing 16 changed files with 1,086 additions and 1,086 deletions.
8 changes: 4 additions & 4 deletions __package__.js
@@ -1,4 +1,4 @@
this.addScript('dom.js',['DOMImplementation','XMLSerializer']);
this.addScript('dom-parser.js',['DOMHandler','DOMParser'],
['DOMImplementation','XMLReader']);
this.addScript('sax.js','XMLReader');
this.addScript('dom.js',['DOMImplementation','XMLSerializer']);
this.addScript('dom-parser.js',['DOMHandler','DOMParser'],
['DOMImplementation','XMLReader']);
this.addScript('sax.js','XMLReader');
42 changes: 21 additions & 21 deletions test/3rd-cases/o3xml.js
@@ -1,21 +1,21 @@
var DOMParser = require('../../lib/dom-parser').DOMParser;
require('./mock')
//Compatibility
{
var doc = new DOMParser().parseFromString("<xml/>",'text/xml');
var np = doc.__proto__.__proto__.__proto__;
for(var n in np){
if(/_NODE$/.test(n)){
// console.log(n.replace(/_NODE$/,''),np[n])
np[n.replace(/_NODE$/,'')] = np[n];
}
}

}

require.cache[require.resolve('node-o3-xml')]
= require.cache[require.resolve('./mock')];
require('node-o3-xml').parseFromString = function(xml){
return new DOMParser().parseFromString(xml,'text/xml');
}
require('node-o3-xml/test/test')
var DOMParser = require('../../lib/dom-parser').DOMParser;
require('./mock')
//Compatibility
{
var doc = new DOMParser().parseFromString("<xml/>",'text/xml');
var np = doc.__proto__.__proto__.__proto__;
for(var n in np){
if(/_NODE$/.test(n)){
// console.log(n.replace(/_NODE$/,''),np[n])
np[n.replace(/_NODE$/,'')] = np[n];
}
}

}

require.cache[require.resolve('node-o3-xml')]
= require.cache[require.resolve('./mock')];
require('node-o3-xml').parseFromString = function(xml){
return new DOMParser().parseFromString(xml,'text/xml');
}
require('node-o3-xml/test/test')
130 changes: 65 additions & 65 deletions test/dom/attr.vows.js
@@ -1,65 +1,65 @@
var wows = require('vows');
var DOMParser = require('../../lib/dom-parser').DOMParser;
const assert = require('../assert')

// Create a Test Suite
wows.describe('XML attrs').addBatch({
"set attribute":function(){
var root = new DOMParser().parseFromString("<xml/>",'text/xml').documentElement;
root.setAttribute('a','1');
assert(root.attributes[0].localName, 'a');
root.setAttribute('b',2);
root.setAttribute('a',1);
root.setAttribute('a',1);
root.setAttribute('a',1);
assert(root.attributes.length, 2);
try {
var c = root.ownerDocument.createElement('c');
c.setAttributeNode(root.attributes.item(0));
} catch (e) {
assert(e.code, 10);
return;
}
assert.fail('expected error but none was thrown');
},
"set ns attribute":function(){
var root = new DOMParser().parseFromString("<xml xmlns:a='a' xmlns:b='b' xmlns='e'><child/></xml>",'text/xml').documentElement;
var child = root.firstChild
child.setAttributeNS('a','a:a','1');
child.setAttributeNS('b','b:b','2');
child.setAttributeNS('b','b:a','1');
assert(child.attributes.length, 3, 'after adding 3', child);
child.setAttribute('a',1);
child.setAttributeNS('b','b:b','2');
assert(child.attributes.length, 4, 'after adding 4 and one with namespace');
try {
var c = root.ownerDocument.createElement('c');
c.setAttributeNodeNS(root.attributes.item(0));
} catch (e) {
assert(e.code, 10, 'wrong error code');
return;
}
assert.fail('expected error but none was thrown');
},
"override attribute":function(){
var root = new DOMParser().parseFromString("<xml xmlns:a='a' xmlns:b='b' xmlns='e'><child/></xml>",'text/xml').documentElement;
root.setAttributeNS('a','a:a','1');
assert(root.attributes.length, 4);
//not standart
// root.firstChild.setAttributeNode(root.attributes[0]);
// assert(root.attributes.length, 0);
},
"attribute namespace":function(){
var root = new DOMParser().parseFromString("<xml xmlns:a='a' xmlns:b='b' a:b='e'></xml>",'text/xml').documentElement;
assert(root.getAttributeNS("a", "b"), "e");
},
"override ns attribute":function(){

},
"set existed attribute":function(){

},
"set document existed attribute":function(){

}
}).export(module); // Run it
var wows = require('vows');
var DOMParser = require('../../lib/dom-parser').DOMParser;
const assert = require('../assert')

// Create a Test Suite
wows.describe('XML attrs').addBatch({
"set attribute":function(){
var root = new DOMParser().parseFromString("<xml/>",'text/xml').documentElement;
root.setAttribute('a','1');
assert(root.attributes[0].localName, 'a');
root.setAttribute('b',2);
root.setAttribute('a',1);
root.setAttribute('a',1);
root.setAttribute('a',1);
assert(root.attributes.length, 2);
try {
var c = root.ownerDocument.createElement('c');
c.setAttributeNode(root.attributes.item(0));
} catch (e) {
assert(e.code, 10);
return;
}
assert.fail('expected error but none was thrown');
},
"set ns attribute":function(){
var root = new DOMParser().parseFromString("<xml xmlns:a='a' xmlns:b='b' xmlns='e'><child/></xml>",'text/xml').documentElement;
var child = root.firstChild
child.setAttributeNS('a','a:a','1');
child.setAttributeNS('b','b:b','2');
child.setAttributeNS('b','b:a','1');
assert(child.attributes.length, 3, 'after adding 3', child);
child.setAttribute('a',1);
child.setAttributeNS('b','b:b','2');
assert(child.attributes.length, 4, 'after adding 4 and one with namespace');
try {
var c = root.ownerDocument.createElement('c');
c.setAttributeNodeNS(root.attributes.item(0));
} catch (e) {
assert(e.code, 10, 'wrong error code');
return;
}
assert.fail('expected error but none was thrown');
},
"override attribute":function(){
var root = new DOMParser().parseFromString("<xml xmlns:a='a' xmlns:b='b' xmlns='e'><child/></xml>",'text/xml').documentElement;
root.setAttributeNS('a','a:a','1');
assert(root.attributes.length, 4);
//not standart
// root.firstChild.setAttributeNode(root.attributes[0]);
// assert(root.attributes.length, 0);
},
"attribute namespace":function(){
var root = new DOMParser().parseFromString("<xml xmlns:a='a' xmlns:b='b' a:b='e'></xml>",'text/xml').documentElement;
assert(root.getAttributeNS("a", "b"), "e");
},
"override ns attribute":function(){

},
"set existed attribute":function(){

},
"set document existed attribute":function(){

}
}).export(module); // Run it
48 changes: 24 additions & 24 deletions test/dom/clone.vows.js
@@ -1,24 +1,24 @@
var wows = require('vows');
var XMLSerializer = require('../../lib/dom-parser').XMLSerializer;
var DOMParser = require('../../lib/dom-parser').DOMParser;
const assert = require('../assert')

// Create a Test Suite
wows.describe('XML Namespace Parse').addBatch({
'clone': function () {
var doc1 = new DOMParser().parseFromString("<doc1 attr1='1' attr2='a2'>text1<child>text2</child></doc1>",'text/xml')
var doc1s = new XMLSerializer().serializeToString(doc1);
var n =doc1.cloneNode(true)
assert(n, doc1s)
},
'import': function () {
var doc1 = new DOMParser().parseFromString("<doc2 attr='2'/>")
var doc2 = new DOMParser().parseFromString("<doc1 attr1='1' attr2='a2'>text1<child>text2</child></doc1>",'text/xml')

var doc3 = new DOMParser().parseFromString("<doc2 attr='2'><doc1 attr1='1' attr2='a2'>text1<child>text2</child></doc1></doc2>")
var n =doc1.importNode(doc2.documentElement, true)
doc1.documentElement.appendChild(n)
assert(doc1, doc3+'')
assert.isTrue(doc2 != doc3+'')
}
}).export(module); // Run it
var wows = require('vows');
var XMLSerializer = require('../../lib/dom-parser').XMLSerializer;
var DOMParser = require('../../lib/dom-parser').DOMParser;
const assert = require('../assert')

// Create a Test Suite
wows.describe('XML Namespace Parse').addBatch({
'clone': function () {
var doc1 = new DOMParser().parseFromString("<doc1 attr1='1' attr2='a2'>text1<child>text2</child></doc1>",'text/xml')
var doc1s = new XMLSerializer().serializeToString(doc1);
var n =doc1.cloneNode(true)
assert(n, doc1s)
},
'import': function () {
var doc1 = new DOMParser().parseFromString("<doc2 attr='2'/>")
var doc2 = new DOMParser().parseFromString("<doc1 attr1='1' attr2='a2'>text1<child>text2</child></doc1>",'text/xml')

var doc3 = new DOMParser().parseFromString("<doc2 attr='2'><doc1 attr1='1' attr2='a2'>text1<child>text2</child></doc1></doc2>")
var n =doc1.importNode(doc2.documentElement, true)
doc1.documentElement.appendChild(n)
assert(doc1, doc3+'')
assert.isTrue(doc2 != doc3+'')
}
}).export(module); // Run it

0 comments on commit 0ade062

Please sign in to comment.