Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Convert all line separators to LF #66

Merged
merged 1 commit into from Jun 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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