vue-reader
Version:
An vue-reader for vue powered by EpubJS
1,613 lines (1,581 loc) • 749 kB
JavaScript
(function (exports, vue) {
'use strict';
function styleInject(css, ref) {
if ( ref === undefined ) ref = {};
var insertAt = ref.insertAt;
if (!css || typeof document === 'undefined') { return; }
var head = document.head || document.getElementsByTagName('head')[0];
var style = document.createElement('style');
style.type = 'text/css';
if (insertAt === 'top') {
if (head.firstChild) {
head.insertBefore(style, head.firstChild);
} else {
head.appendChild(style);
}
} else {
head.appendChild(style);
}
if (style.styleSheet) {
style.styleSheet.cssText = css;
} else {
style.appendChild(document.createTextNode(css));
}
}
var css_248z$1 = ".reader{inset:50px 50px 20px;position:absolute}.viewHolder{height:100%;position:relative;width:100%}#viewer{height:100%}";
styleInject(css_248z$1);
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
function getDefaultExportFromCjs (x) {
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
}
var eventEmitter = {exports: {}};
var d$1 = {exports: {}};
var _undefined$1 = undefined;
var is$4 = function (value) { return value !== _undefined$1 && value !== null; };
getDefaultExportFromCjs(is$4);
var isValue$3 = is$4;
var possibleTypes = { "object": true, "function": true, "undefined": true };
var is$3 = function (value) {
if (!isValue$3(value)) return false;
return hasOwnProperty.call(possibleTypes, typeof value);
};
getDefaultExportFromCjs(is$3);
var isObject$4 = is$3;
var is$2 = function (value) {
if (!isObject$4(value)) return false;
try {
if (!value.constructor) return false;
return value.constructor.prototype === value;
} catch (error) {
return false;
}
};
getDefaultExportFromCjs(is$2);
var isPrototype = is$2;
var is$1 = function (value) {
if (typeof value !== "function") return false;
if (!hasOwnProperty.call(value, "length")) return false;
try {
if (typeof value.length !== "number") return false;
if (typeof value.call !== "function") return false;
if (typeof value.apply !== "function") return false;
} catch (error) {
return false;
}
return !isPrototype(value);
};
getDefaultExportFromCjs(is$1);
var isFunction = is$1;
var classRe = /^\s*class[\s{/}]/, functionToString = Function.prototype.toString;
var is = function (value) {
if (!isFunction(value)) return false;
if (classRe.test(functionToString.call(value))) return false;
return true;
};
getDefaultExportFromCjs(is);
var isImplemented$2 = function () {
var assign = Object.assign, obj;
if (typeof assign !== "function") return false;
obj = { foo: "raz" };
assign(obj, { bar: "dwa" }, { trzy: "trzy" });
return obj.foo + obj.bar + obj.trzy === "razdwatrzy";
};
getDefaultExportFromCjs(isImplemented$2);
var isImplemented$1;
var hasRequiredIsImplemented;
function requireIsImplemented () {
if (hasRequiredIsImplemented) return isImplemented$1;
hasRequiredIsImplemented = 1;
isImplemented$1 = function () {
try {
Object.keys("primitive");
return true;
} catch (e) {
return false;
}
};
return isImplemented$1;
}
var noop = function () {};
getDefaultExportFromCjs(noop);
var _undefined = noop();
var isValue$2 = function (val) { return val !== _undefined && val !== null; };
getDefaultExportFromCjs(isValue$2);
var shim$2;
var hasRequiredShim$2;
function requireShim$2 () {
if (hasRequiredShim$2) return shim$2;
hasRequiredShim$2 = 1;
var isValue = isValue$2;
var keys = Object.keys;
shim$2 = function (object) { return keys(isValue(object) ? Object(object) : object); };
return shim$2;
}
var keys;
var hasRequiredKeys;
function requireKeys () {
if (hasRequiredKeys) return keys;
hasRequiredKeys = 1;
keys = requireIsImplemented()() ? Object.keys : requireShim$2();
return keys;
}
var validValue;
var hasRequiredValidValue;
function requireValidValue () {
if (hasRequiredValidValue) return validValue;
hasRequiredValidValue = 1;
var isValue = isValue$2;
validValue = function (value) {
if (!isValue(value)) throw new TypeError("Cannot use null or undefined");
return value;
};
return validValue;
}
var shim$1;
var hasRequiredShim$1;
function requireShim$1 () {
if (hasRequiredShim$1) return shim$1;
hasRequiredShim$1 = 1;
var keys = requireKeys()
, value = requireValidValue()
, max = Math.max;
shim$1 = function (dest, src ) {
var error, i, length = max(arguments.length, 2), assign;
dest = Object(value(dest));
assign = function (key) {
try {
dest[key] = src[key];
} catch (e) {
if (!error) error = e;
}
};
for (i = 1; i < length; ++i) {
src = arguments[i];
keys(src).forEach(assign);
}
if (error !== undefined) throw error;
return dest;
};
return shim$1;
}
var assign$1 = isImplemented$2() ? Object.assign : requireShim$1();
getDefaultExportFromCjs(assign$1);
var isValue$1 = isValue$2;
var forEach = Array.prototype.forEach, create = Object.create;
var process$2 = function (src, obj) {
var key;
for (key in src) obj[key] = src[key];
};
var normalizeOptions = function (opts1 ) {
var result = create(null);
forEach.call(arguments, function (options) {
if (!isValue$1(options)) return;
process$2(Object(options), result);
});
return result;
};
getDefaultExportFromCjs(normalizeOptions);
var str = "razdwatrzy";
var isImplemented = function () {
if (typeof str.contains !== "function") return false;
return str.contains("dwa") === true && str.contains("foo") === false;
};
getDefaultExportFromCjs(isImplemented);
var shim;
var hasRequiredShim;
function requireShim () {
if (hasRequiredShim) return shim;
hasRequiredShim = 1;
var indexOf = String.prototype.indexOf;
shim = function (searchString ) {
return indexOf.call(this, searchString, arguments[1]) > -1;
};
return shim;
}
var contains$3 = isImplemented() ? String.prototype.contains : requireShim();
getDefaultExportFromCjs(contains$3);
var isValue = is$4
, isPlainFunction = is
, assign = assign$1
, normalizeOpts = normalizeOptions
, contains$2 = contains$3;
var d = (d$1.exports = function (dscr, value) {
var c, e, w, options, desc;
if (arguments.length < 2 || typeof dscr !== "string") {
options = value;
value = dscr;
dscr = null;
} else {
options = arguments[2];
}
if (isValue(dscr)) {
c = contains$2.call(dscr, "c");
e = contains$2.call(dscr, "e");
w = contains$2.call(dscr, "w");
} else {
c = w = true;
e = false;
}
desc = { value: value, configurable: c, enumerable: e, writable: w };
return !options ? desc : assign(normalizeOpts(options), desc);
});
d.gs = function (dscr, get, set) {
var c, e, options, desc;
if (typeof dscr !== "string") {
options = set;
set = get;
get = dscr;
dscr = null;
} else {
options = arguments[3];
}
if (!isValue(get)) {
get = undefined;
} else if (!isPlainFunction(get)) {
options = get;
get = set = undefined;
} else if (!isValue(set)) {
set = undefined;
} else if (!isPlainFunction(set)) {
options = set;
set = undefined;
}
if (isValue(dscr)) {
c = contains$2.call(dscr, "c");
e = contains$2.call(dscr, "e");
} else {
c = true;
e = false;
}
desc = { get: get, set: set, configurable: c, enumerable: e };
return !options ? desc : assign(normalizeOpts(options), desc);
};
var dExports = d$1.exports;
getDefaultExportFromCjs(dExports);
var validCallable = function (fn) {
if (typeof fn !== "function") throw new TypeError(fn + " is not a function");
return fn;
};
getDefaultExportFromCjs(validCallable);
(function (module, exports) {
var d = dExports
, callable = validCallable
, apply = Function.prototype.apply, call = Function.prototype.call
, create = Object.create, defineProperty = Object.defineProperty
, defineProperties = Object.defineProperties
, hasOwnProperty = Object.prototype.hasOwnProperty
, descriptor = { configurable: true, enumerable: false, writable: true }
, on, once, off, emit, methods, descriptors, base;
on = function (type, listener) {
var data;
callable(listener);
if (!hasOwnProperty.call(this, '__ee__')) {
data = descriptor.value = create(null);
defineProperty(this, '__ee__', descriptor);
descriptor.value = null;
} else {
data = this.__ee__;
}
if (!data[type]) data[type] = listener;
else if (typeof data[type] === 'object') data[type].push(listener);
else data[type] = [data[type], listener];
return this;
};
once = function (type, listener) {
var once, self;
callable(listener);
self = this;
on.call(this, type, once = function () {
off.call(self, type, once);
apply.call(listener, this, arguments);
});
once.__eeOnceListener__ = listener;
return this;
};
off = function (type, listener) {
var data, listeners, candidate, i;
callable(listener);
if (!hasOwnProperty.call(this, '__ee__')) return this;
data = this.__ee__;
if (!data[type]) return this;
listeners = data[type];
if (typeof listeners === 'object') {
for (i = 0; (candidate = listeners[i]); ++i) {
if ((candidate === listener) ||
(candidate.__eeOnceListener__ === listener)) {
if (listeners.length === 2) data[type] = listeners[i ? 0 : 1];
else listeners.splice(i, 1);
}
}
} else {
if ((listeners === listener) ||
(listeners.__eeOnceListener__ === listener)) {
delete data[type];
}
}
return this;
};
emit = function (type) {
var i, l, listener, listeners, args;
if (!hasOwnProperty.call(this, '__ee__')) return;
listeners = this.__ee__[type];
if (!listeners) return;
if (typeof listeners === 'object') {
l = arguments.length;
args = new Array(l - 1);
for (i = 1; i < l; ++i) args[i - 1] = arguments[i];
listeners = listeners.slice();
for (i = 0; (listener = listeners[i]); ++i) {
apply.call(listener, this, args);
}
} else {
switch (arguments.length) {
case 1:
call.call(listeners, this);
break;
case 2:
call.call(listeners, this, arguments[1]);
break;
case 3:
call.call(listeners, this, arguments[1], arguments[2]);
break;
default:
l = arguments.length;
args = new Array(l - 1);
for (i = 1; i < l; ++i) {
args[i - 1] = arguments[i];
}
apply.call(listeners, this, args);
}
}
};
methods = {
on: on,
once: once,
off: off,
emit: emit
};
descriptors = {
on: d(on),
once: d(once),
off: d(off),
emit: d(emit)
};
base = defineProperties({}, descriptors);
module.exports = exports = function (o) {
return (o == null) ? create(base) : defineProperties(Object(o), descriptors);
};
exports.methods = methods;
} (eventEmitter, eventEmitter.exports));
var eventEmitterExports = eventEmitter.exports;
var EventEmitter = getDefaultExportFromCjs(eventEmitterExports);
var dom$1 = {};
var conventions$2 = {};
function find$1(list, predicate, ac) {
if (ac === undefined) {
ac = Array.prototype;
}
if (list && typeof ac.find === 'function') {
return ac.find.call(list, predicate);
}
for (var i = 0; i < list.length; i++) {
if (Object.prototype.hasOwnProperty.call(list, i)) {
var item = list[i];
if (predicate.call(undefined, item, i, list)) {
return item;
}
}
}
}
function freeze(object, oc) {
if (oc === undefined) {
oc = Object;
}
return oc && typeof oc.freeze === 'function' ? oc.freeze(object) : object
}
var MIME_TYPE = freeze({
HTML: 'text/html',
isHTML: function (value) {
return value === MIME_TYPE.HTML
},
XML_APPLICATION: 'application/xml',
XML_TEXT: 'text/xml',
XML_XHTML_APPLICATION: 'application/xhtml+xml',
XML_SVG_IMAGE: 'image/svg+xml',
});
var NAMESPACE$3 = freeze({
HTML: 'http://www.w3.org/1999/xhtml',
isHTML: function (uri) {
return uri === NAMESPACE$3.HTML
},
SVG: 'http://www.w3.org/2000/svg',
XML: 'http://www.w3.org/XML/1998/namespace',
XMLNS: 'http://www.w3.org/2000/xmlns/',
});
conventions$2.find = find$1;
conventions$2.freeze = freeze;
conventions$2.MIME_TYPE = MIME_TYPE;
conventions$2.NAMESPACE = NAMESPACE$3;
var conventions$1 = conventions$2;
var find = conventions$1.find;
var NAMESPACE$2 = conventions$1.NAMESPACE;
function notEmptyString (input) {
return input !== ''
}
function splitOnASCIIWhitespace(input) {
return input ? input.split(/[\t\n\f\r ]+/).filter(notEmptyString) : []
}
function orderedSetReducer (current, element) {
if (!current.hasOwnProperty(element)) {
current[element] = true;
}
return current;
}
function toOrderedSet(input) {
if (!input) return [];
var list = splitOnASCIIWhitespace(input);
return Object.keys(list.reduce(orderedSetReducer, {}))
}
function arrayIncludes (list) {
return function(element) {
return list && list.indexOf(element) !== -1;
}
}
function copy(src,dest){
for(var p in src){
if (Object.prototype.hasOwnProperty.call(src, p)) {
dest[p] = src[p];
}
}
}
function _extends(Class,Super){
var pt = Class.prototype;
if(!(pt instanceof Super)){
function t(){} t.prototype = Super.prototype;
t = new t();
copy(pt,t);
Class.prototype = pt = t;
}
if(pt.constructor != Class){
pt.constructor = Class;
}
}
var NodeType = {};
var ELEMENT_NODE$3 = NodeType.ELEMENT_NODE = 1;
var ATTRIBUTE_NODE = NodeType.ATTRIBUTE_NODE = 2;
var TEXT_NODE$2 = NodeType.TEXT_NODE = 3;
var CDATA_SECTION_NODE = NodeType.CDATA_SECTION_NODE = 4;
var ENTITY_REFERENCE_NODE = NodeType.ENTITY_REFERENCE_NODE = 5;
var ENTITY_NODE = NodeType.ENTITY_NODE = 6;
var PROCESSING_INSTRUCTION_NODE = NodeType.PROCESSING_INSTRUCTION_NODE = 7;
var COMMENT_NODE = NodeType.COMMENT_NODE = 8;
var DOCUMENT_NODE$1 = NodeType.DOCUMENT_NODE = 9;
var DOCUMENT_TYPE_NODE = NodeType.DOCUMENT_TYPE_NODE = 10;
var DOCUMENT_FRAGMENT_NODE = NodeType.DOCUMENT_FRAGMENT_NODE = 11;
var NOTATION_NODE = NodeType.NOTATION_NODE = 12;
var ExceptionCode = {};
var ExceptionMessage = {};
ExceptionCode.INDEX_SIZE_ERR = ((ExceptionMessage[1]="Index size error"),1);
ExceptionCode.DOMSTRING_SIZE_ERR = ((ExceptionMessage[2]="DOMString size error"),2);
var HIERARCHY_REQUEST_ERR = ExceptionCode.HIERARCHY_REQUEST_ERR = ((ExceptionMessage[3]="Hierarchy request error"),3);
ExceptionCode.WRONG_DOCUMENT_ERR = ((ExceptionMessage[4]="Wrong document"),4);
ExceptionCode.INVALID_CHARACTER_ERR = ((ExceptionMessage[5]="Invalid character"),5);
ExceptionCode.NO_DATA_ALLOWED_ERR = ((ExceptionMessage[6]="No data allowed"),6);
ExceptionCode.NO_MODIFICATION_ALLOWED_ERR = ((ExceptionMessage[7]="No modification allowed"),7);
var NOT_FOUND_ERR = ExceptionCode.NOT_FOUND_ERR = ((ExceptionMessage[8]="Not found"),8);
ExceptionCode.NOT_SUPPORTED_ERR = ((ExceptionMessage[9]="Not supported"),9);
var INUSE_ATTRIBUTE_ERR = ExceptionCode.INUSE_ATTRIBUTE_ERR = ((ExceptionMessage[10]="Attribute in use"),10);
ExceptionCode.INVALID_STATE_ERR = ((ExceptionMessage[11]="Invalid state"),11);
ExceptionCode.SYNTAX_ERR = ((ExceptionMessage[12]="Syntax error"),12);
ExceptionCode.INVALID_MODIFICATION_ERR = ((ExceptionMessage[13]="Invalid modification"),13);
ExceptionCode.NAMESPACE_ERR = ((ExceptionMessage[14]="Invalid namespace"),14);
ExceptionCode.INVALID_ACCESS_ERR = ((ExceptionMessage[15]="Invalid access"),15);
function DOMException(code, message) {
if(message instanceof Error){
var error = message;
}else {
error = this;
Error.call(this, ExceptionMessage[code]);
this.message = ExceptionMessage[code];
if(Error.captureStackTrace) Error.captureStackTrace(this, DOMException);
}
error.code = code;
if(message) this.message = this.message + ": " + message;
return error;
}DOMException.prototype = Error.prototype;
copy(ExceptionCode,DOMException);
function NodeList() {
}NodeList.prototype = {
length:0,
item: function(index) {
return index >= 0 && index < this.length ? this[index] : null;
},
toString:function(isHTML,nodeFilter){
for(var buf = [], i = 0;i<this.length;i++){
serializeToString(this[i],buf,isHTML,nodeFilter);
}
return buf.join('');
},
filter: function (predicate) {
return Array.prototype.filter.call(this, predicate);
},
indexOf: function (item) {
return Array.prototype.indexOf.call(this, item);
},
};
function LiveNodeList(node,refresh){
this._node = node;
this._refresh = refresh;
_updateLiveList(this);
}
function _updateLiveList(list){
var inc = list._node._inc || list._node.ownerDocument._inc;
if (list._inc !== inc) {
var ls = list._refresh(list._node);
__set__(list,'length',ls.length);
if (!list.$$length || ls.length < list.$$length) {
for (var i = ls.length; i in list; i++) {
if (Object.prototype.hasOwnProperty.call(list, i)) {
delete list[i];
}
}
}
copy(ls,list);
list._inc = inc;
}
}
LiveNodeList.prototype.item = function(i){
_updateLiveList(this);
return this[i] || null;
};
_extends(LiveNodeList,NodeList);
function NamedNodeMap() {
}function _findNodeIndex(list,node){
var i = list.length;
while(i--){
if(list[i] === node){return i}
}
}
function _addNamedNode(el,list,newAttr,oldAttr){
if(oldAttr){
list[_findNodeIndex(list,oldAttr)] = newAttr;
}else {
list[list.length++] = newAttr;
}
if(el){
newAttr.ownerElement = el;
var doc = el.ownerDocument;
if(doc){
oldAttr && _onRemoveAttribute(doc,el,oldAttr);
_onAddAttribute(doc,el,newAttr);
}
}
}
function _removeNamedNode(el,list,attr){
var i = _findNodeIndex(list,attr);
if(i>=0){
var lastIndex = list.length-1;
while(i<lastIndex){
list[i] = list[++i];
}
list.length = lastIndex;
if(el){
var doc = el.ownerDocument;
if(doc){
_onRemoveAttribute(doc,el,attr);
attr.ownerElement = null;
}
}
}else {
throw new DOMException(NOT_FOUND_ERR,new Error(el.tagName+'@'+attr))
}
}
NamedNodeMap.prototype = {
length:0,
item:NodeList.prototype.item,
getNamedItem: function(key) {
var i = this.length;
while(i--){
var attr = this[i];
if(attr.nodeName == key){
return attr;
}
}
},
setNamedItem: function(attr) {
var el = attr.ownerElement;
if(el && el!=this._ownerElement){
throw new DOMException(INUSE_ATTRIBUTE_ERR);
}
var oldAttr = this.getNamedItem(attr.nodeName);
_addNamedNode(this._ownerElement,this,attr,oldAttr);
return oldAttr;
},
setNamedItemNS: function(attr) {
var el = attr.ownerElement, oldAttr;
if(el && el!=this._ownerElement){
throw new DOMException(INUSE_ATTRIBUTE_ERR);
}
oldAttr = this.getNamedItemNS(attr.namespaceURI,attr.localName);
_addNamedNode(this._ownerElement,this,attr,oldAttr);
return oldAttr;
},
removeNamedItem: function(key) {
var attr = this.getNamedItem(key);
_removeNamedNode(this._ownerElement,this,attr);
return attr;
},
removeNamedItemNS:function(namespaceURI,localName){
var attr = this.getNamedItemNS(namespaceURI,localName);
_removeNamedNode(this._ownerElement,this,attr);
return attr;
},
getNamedItemNS: function(namespaceURI, localName) {
var i = this.length;
while(i--){
var node = this[i];
if(node.localName == localName && node.namespaceURI == namespaceURI){
return node;
}
}
return null;
}
};
function DOMImplementation$1() {
}
DOMImplementation$1.prototype = {
hasFeature: function(feature, version) {
return true;
},
createDocument: function(namespaceURI, qualifiedName, doctype){
var doc = new Document();
doc.implementation = this;
doc.childNodes = new NodeList();
doc.doctype = doctype || null;
if (doctype){
doc.appendChild(doctype);
}
if (qualifiedName){
var root = doc.createElementNS(namespaceURI, qualifiedName);
doc.appendChild(root);
}
return doc;
},
createDocumentType: function(qualifiedName, publicId, systemId){
var node = new DocumentType();
node.name = qualifiedName;
node.nodeName = qualifiedName;
node.publicId = publicId || '';
node.systemId = systemId || '';
return node;
}
};
function Node$1() {
}Node$1.prototype = {
firstChild : null,
lastChild : null,
previousSibling : null,
nextSibling : null,
attributes : null,
parentNode : null,
childNodes : null,
ownerDocument : null,
nodeValue : null,
namespaceURI : null,
prefix : null,
localName : null,
insertBefore:function(newChild, refChild){
return _insertBefore(this,newChild,refChild);
},
replaceChild:function(newChild, oldChild){
_insertBefore(this, newChild,oldChild, assertPreReplacementValidityInDocument);
if(oldChild){
this.removeChild(oldChild);
}
},
removeChild:function(oldChild){
return _removeChild(this,oldChild);
},
appendChild:function(newChild){
return this.insertBefore(newChild,null);
},
hasChildNodes:function(){
return this.firstChild != null;
},
cloneNode:function(deep){
return cloneNode(this.ownerDocument||this,this,deep);
},
normalize:function(){
var child = this.firstChild;
while(child){
var next = child.nextSibling;
if(next && next.nodeType == TEXT_NODE$2 && child.nodeType == TEXT_NODE$2){
this.removeChild(next);
child.appendData(next.data);
}else {
child.normalize();
child = next;
}
}
},
isSupported:function(feature, version){
return this.ownerDocument.implementation.hasFeature(feature,version);
},
hasAttributes:function(){
return this.attributes.length>0;
},
lookupPrefix:function(namespaceURI){
var el = this;
while(el){
var map = el._nsMap;
if(map){
for(var n in map){
if (Object.prototype.hasOwnProperty.call(map, n) && map[n] === namespaceURI) {
return n;
}
}
}
el = el.nodeType == ATTRIBUTE_NODE?el.ownerDocument : el.parentNode;
}
return null;
},
lookupNamespaceURI:function(prefix){
var el = this;
while(el){
var map = el._nsMap;
if(map){
if(prefix in map){
if(Object.prototype.hasOwnProperty.call(map, prefix)){
return map[prefix] ;
}
}
}
el = el.nodeType == ATTRIBUTE_NODE?el.ownerDocument : el.parentNode;
}
return null;
},
isDefaultNamespace:function(namespaceURI){
var prefix = this.lookupPrefix(namespaceURI);
return prefix == null;
}
};
function _xmlEncoder(c){
return c == '<' && '<' ||
c == '>' && '>' ||
c == '&' && '&' ||
c == '"' && '"' ||
'&#'+c.charCodeAt()+';'
}
copy(NodeType,Node$1);
copy(NodeType,Node$1.prototype);
function _visitNode(node,callback){
if(callback(node)){
return true;
}
if(node = node.firstChild){
do{
if(_visitNode(node,callback)){return true}
}while(node=node.nextSibling)
}
}
function Document(){
this.ownerDocument = this;
}
function _onAddAttribute(doc,el,newAttr){
doc && doc._inc++;
var ns = newAttr.namespaceURI ;
if(ns === NAMESPACE$2.XMLNS){
el._nsMap[newAttr.prefix?newAttr.localName:''] = newAttr.value;
}
}
function _onRemoveAttribute(doc,el,newAttr,remove){
doc && doc._inc++;
var ns = newAttr.namespaceURI ;
if(ns === NAMESPACE$2.XMLNS){
delete el._nsMap[newAttr.prefix?newAttr.localName:''];
}
}
function _onUpdateChild(doc,el,newChild){
if(doc && doc._inc){
doc._inc++;
var cs = el.childNodes;
if(newChild){
cs[cs.length++] = newChild;
}else {
var child = el.firstChild;
var i = 0;
while(child){
cs[i++] = child;
child =child.nextSibling;
}
cs.length = i;
delete cs[cs.length];
}
}
}
function _removeChild(parentNode,child){
var previous = child.previousSibling;
var next = child.nextSibling;
if(previous){
previous.nextSibling = next;
}else {
parentNode.firstChild = next;
}
if(next){
next.previousSibling = previous;
}else {
parentNode.lastChild = previous;
}
child.parentNode = null;
child.previousSibling = null;
child.nextSibling = null;
_onUpdateChild(parentNode.ownerDocument,parentNode);
return child;
}
function hasValidParentNodeType(node) {
return (
node &&
(node.nodeType === Node$1.DOCUMENT_NODE || node.nodeType === Node$1.DOCUMENT_FRAGMENT_NODE || node.nodeType === Node$1.ELEMENT_NODE)
);
}
function hasInsertableNodeType(node) {
return (
node &&
(isElementNode(node) ||
isTextNode(node) ||
isDocTypeNode(node) ||
node.nodeType === Node$1.DOCUMENT_FRAGMENT_NODE ||
node.nodeType === Node$1.COMMENT_NODE ||
node.nodeType === Node$1.PROCESSING_INSTRUCTION_NODE)
);
}
function isDocTypeNode(node) {
return node && node.nodeType === Node$1.DOCUMENT_TYPE_NODE;
}
function isElementNode(node) {
return node && node.nodeType === Node$1.ELEMENT_NODE;
}
function isTextNode(node) {
return node && node.nodeType === Node$1.TEXT_NODE;
}
function isElementInsertionPossible(doc, child) {
var parentChildNodes = doc.childNodes || [];
if (find(parentChildNodes, isElementNode) || isDocTypeNode(child)) {
return false;
}
var docTypeNode = find(parentChildNodes, isDocTypeNode);
return !(child && docTypeNode && parentChildNodes.indexOf(docTypeNode) > parentChildNodes.indexOf(child));
}
function isElementReplacementPossible(doc, child) {
var parentChildNodes = doc.childNodes || [];
function hasElementChildThatIsNotChild(node) {
return isElementNode(node) && node !== child;
}
if (find(parentChildNodes, hasElementChildThatIsNotChild)) {
return false;
}
var docTypeNode = find(parentChildNodes, isDocTypeNode);
return !(child && docTypeNode && parentChildNodes.indexOf(docTypeNode) > parentChildNodes.indexOf(child));
}
function assertPreInsertionValidity1to5(parent, node, child) {
if (!hasValidParentNodeType(parent)) {
throw new DOMException(HIERARCHY_REQUEST_ERR, 'Unexpected parent node type ' + parent.nodeType);
}
if (child && child.parentNode !== parent) {
throw new DOMException(NOT_FOUND_ERR, 'child not in parent');
}
if (
!hasInsertableNodeType(node) ||
(isDocTypeNode(node) && parent.nodeType !== Node$1.DOCUMENT_NODE)
) {
throw new DOMException(
HIERARCHY_REQUEST_ERR,
'Unexpected node type ' + node.nodeType + ' for parent node type ' + parent.nodeType
);
}
}
function assertPreInsertionValidityInDocument(parent, node, child) {
var parentChildNodes = parent.childNodes || [];
var nodeChildNodes = node.childNodes || [];
if (node.nodeType === Node$1.DOCUMENT_FRAGMENT_NODE) {
var nodeChildElements = nodeChildNodes.filter(isElementNode);
if (nodeChildElements.length > 1 || find(nodeChildNodes, isTextNode)) {
throw new DOMException(HIERARCHY_REQUEST_ERR, 'More than one element or text in fragment');
}
if (nodeChildElements.length === 1 && !isElementInsertionPossible(parent, child)) {
throw new DOMException(HIERARCHY_REQUEST_ERR, 'Element in fragment can not be inserted before doctype');
}
}
if (isElementNode(node)) {
if (!isElementInsertionPossible(parent, child)) {
throw new DOMException(HIERARCHY_REQUEST_ERR, 'Only one element can be added and only after doctype');
}
}
if (isDocTypeNode(node)) {
if (find(parentChildNodes, isDocTypeNode)) {
throw new DOMException(HIERARCHY_REQUEST_ERR, 'Only one doctype is allowed');
}
var parentElementChild = find(parentChildNodes, isElementNode);
if (child && parentChildNodes.indexOf(parentElementChild) < parentChildNodes.indexOf(child)) {
throw new DOMException(HIERARCHY_REQUEST_ERR, 'Doctype can only be inserted before an element');
}
if (!child && parentElementChild) {
throw new DOMException(HIERARCHY_REQUEST_ERR, 'Doctype can not be appended since element is present');
}
}
}
function assertPreReplacementValidityInDocument(parent, node, child) {
var parentChildNodes = parent.childNodes || [];
var nodeChildNodes = node.childNodes || [];
if (node.nodeType === Node$1.DOCUMENT_FRAGMENT_NODE) {
var nodeChildElements = nodeChildNodes.filter(isElementNode);
if (nodeChildElements.length > 1 || find(nodeChildNodes, isTextNode)) {
throw new DOMException(HIERARCHY_REQUEST_ERR, 'More than one element or text in fragment');
}
if (nodeChildElements.length === 1 && !isElementReplacementPossible(parent, child)) {
throw new DOMException(HIERARCHY_REQUEST_ERR, 'Element in fragment can not be inserted before doctype');
}
}
if (isElementNode(node)) {
if (!isElementReplacementPossible(parent, child)) {
throw new DOMException(HIERARCHY_REQUEST_ERR, 'Only one element can be added and only after doctype');
}
}
if (isDocTypeNode(node)) {
function hasDoctypeChildThatIsNotChild(node) {
return isDocTypeNode(node) && node !== child;
}
if (find(parentChildNodes, hasDoctypeChildThatIsNotChild)) {
throw new DOMException(HIERARCHY_REQUEST_ERR, 'Only one doctype is allowed');
}
var parentElementChild = find(parentChildNodes, isElementNode);
if (child && parentChildNodes.indexOf(parentElementChild) < parentChildNodes.indexOf(child)) {
throw new DOMException(HIERARCHY_REQUEST_ERR, 'Doctype can only be inserted before an element');
}
}
}
function _insertBefore(parent, node, child, _inDocumentAssertion) {
assertPreInsertionValidity1to5(parent, node, child);
if (parent.nodeType === Node$1.DOCUMENT_NODE) {
(_inDocumentAssertion || assertPreInsertionValidityInDocument)(parent, node, child);
}
var cp = node.parentNode;
if(cp){
cp.removeChild(node);
}
if(node.nodeType === DOCUMENT_FRAGMENT_NODE){
var newFirst = node.firstChild;
if (newFirst == null) {
return node;
}
var newLast = node.lastChild;
}else {
newFirst = newLast = node;
}
var pre = child ? child.previousSibling : parent.lastChild;
newFirst.previousSibling = pre;
newLast.nextSibling = child;
if(pre){
pre.nextSibling = newFirst;
}else {
parent.firstChild = newFirst;
}
if(child == null){
parent.lastChild = newLast;
}else {
child.previousSibling = newLast;
}
do{
newFirst.parentNode = parent;
}while(newFirst !== newLast && (newFirst= newFirst.nextSibling))
_onUpdateChild(parent.ownerDocument||parent, parent);
if (node.nodeType == DOCUMENT_FRAGMENT_NODE) {
node.firstChild = node.lastChild = null;
}
return node;
}
function _appendSingleChild(parentNode,newChild){
if (newChild.parentNode) {
newChild.parentNode.removeChild(newChild);
}
newChild.parentNode = parentNode;
newChild.previousSibling = parentNode.lastChild;
newChild.nextSibling = null;
if (newChild.previousSibling) {
newChild.previousSibling.nextSibling = newChild;
}else {
parentNode.firstChild = newChild;
}
parentNode.lastChild = newChild;
_onUpdateChild(parentNode.ownerDocument,parentNode,newChild);
return newChild;
}
Document.prototype = {
nodeName : '#document',
nodeType : DOCUMENT_NODE$1,
doctype : null,
documentElement : null,
_inc : 1,
insertBefore : function(newChild, refChild){
if(newChild.nodeType == DOCUMENT_FRAGMENT_NODE){
var child = newChild.firstChild;
while(child){
var next = child.nextSibling;
this.insertBefore(child,refChild);
child = next;
}
return newChild;
}
_insertBefore(this, newChild, refChild);
newChild.ownerDocument = this;
if (this.documentElement === null && newChild.nodeType === ELEMENT_NODE$3) {
this.documentElement = newChild;
}
return newChild;
},
removeChild : function(oldChild){
if(this.documentElement == oldChild){
this.documentElement = null;
}
return _removeChild(this,oldChild);
},
replaceChild: function (newChild, oldChild) {
_insertBefore(this, newChild, oldChild, assertPreReplacementValidityInDocument);
newChild.ownerDocument = this;
if (oldChild) {
this.removeChild(oldChild);
}
if (isElementNode(newChild)) {
this.documentElement = newChild;
}
},
importNode : function(importedNode,deep){
return importNode(this,importedNode,deep);
},
getElementById : function(id){
var rtv = null;
_visitNode(this.documentElement,function(node){
if(node.nodeType == ELEMENT_NODE$3){
if(node.getAttribute('id') == id){
rtv = node;
return true;
}
}
});
return rtv;
},
getElementsByClassName: function(classNames) {
var classNamesSet = toOrderedSet(classNames);
return new LiveNodeList(this, function(base) {
var ls = [];
if (classNamesSet.length > 0) {
_visitNode(base.documentElement, function(node) {
if(node !== base && node.nodeType === ELEMENT_NODE$3) {
var nodeClassNames = node.getAttribute('class');
if (nodeClassNames) {
var matches = classNames === nodeClassNames;
if (!matches) {
var nodeClassNamesSet = toOrderedSet(nodeClassNames);
matches = classNamesSet.every(arrayIncludes(nodeClassNamesSet));
}
if(matches) {
ls.push(node);
}
}
}
});
}
return ls;
});
},
createElement : function(tagName){
var node = new Element$1();
node.ownerDocument = this;
node.nodeName = tagName;
node.tagName = tagName;
node.localName = tagName;
node.childNodes = new NodeList();
var attrs = node.attributes = new NamedNodeMap();
attrs._ownerElement = node;
return node;
},
createDocumentFragment : function(){
var node = new DocumentFragment();
node.ownerDocument = this;
node.childNodes = new NodeList();
return node;
},
createTextNode : function(data){
var node = new Text();
node.ownerDocument = this;
node.appendData(data);
return node;
},
createComment : function(data){
var node = new Comment();
node.ownerDocument = this;
node.appendData(data);
return node;
},
createCDATASection : function(data){
var node = new CDATASection();
node.ownerDocument = this;
node.appendData(data);
return node;
},
createProcessingInstruction : function(target,data){
var node = new ProcessingInstruction();
node.ownerDocument = this;
node.tagName = node.nodeName = node.target = target;
node.nodeValue = node.data = data;
return node;
},
createAttribute : function(name){
var node = new Attr();
node.ownerDocument = this;
node.name = name;
node.nodeName = name;
node.localName = name;
node.specified = true;
return node;
},
createEntityReference : function(name){
var node = new EntityReference();
node.ownerDocument = this;
node.nodeName = name;
return node;
},
createElementNS : function(namespaceURI,qualifiedName){
var node = new Element$1();
var pl = qualifiedName.split(':');
var attrs = node.attributes = new NamedNodeMap();
node.childNodes = new NodeList();
node.ownerDocument = this;
node.nodeName = qualifiedName;
node.tagName = qualifiedName;
node.namespaceURI = namespaceURI;
if(pl.length == 2){
node.prefix = pl[0];
node.localName = pl[1];
}else {
node.localName = qualifiedName;
}
attrs._ownerElement = node;
return node;
},
createAttributeNS : function(namespaceURI,qualifiedName){
var node = new Attr();
var pl = qualifiedName.split(':');
node.ownerDocument = this;
node.nodeName = qualifiedName;
node.name = qualifiedName;
node.namespaceURI = namespaceURI;
node.specified = true;
if(pl.length == 2){
node.prefix = pl[0];
node.localName = pl[1];
}else {
node.localName = qualifiedName;
}
return node;
}
};
_extends(Document,Node$1);
function Element$1() {
this._nsMap = {};
}Element$1.prototype = {
nodeType : ELEMENT_NODE$3,
hasAttribute : function(name){
return this.getAttributeNode(name)!=null;
},
getAttribute : function(name){
var attr = this.getAttributeNode(name);
return attr && attr.value || '';
},
getAttributeNode : function(name){
return this.attributes.getNamedItem(name);
},
setAttribute : function(name, value){
var attr = this.ownerDocument.createAttribute(name);
attr.value = attr.nodeValue = "" + value;
this.setAttributeNode(attr);
},
removeAttribute : function(name){
var attr = this.getAttributeNode(name);
attr && this.removeAttributeNode(attr);
},
appendChild:function(newChild){
if(newChild.nodeType === DOCUMENT_FRAGMENT_NODE){
return this.insertBefore(newChild,null);
}else {
return _appendSingleChild(this,newChild);
}
},
setAttributeNode : function(newAttr){
return this.attributes.setNamedItem(newAttr);
},
setAttributeNodeNS : function(newAttr){
return this.attributes.setNamedItemNS(newAttr);
},
removeAttributeNode : function(oldAttr){
return this.attributes.removeNamedItem(oldAttr.nodeName);
},
removeAttributeNS : function(namespaceURI, localName){
var old = this.getAttributeNodeNS(namespaceURI, localName);
old && this.removeAttributeNode(old);
},
hasAttributeNS : function(namespaceURI, localName){
return this.getAttributeNodeNS(namespaceURI, localName)!=null;
},
getAttributeNS : function(namespaceURI, localName){
var attr = this.getAttributeNodeNS(namespaceURI, localName);
return attr && attr.value || '';
},
setAttributeNS : function(namespaceURI, qualifiedName, value){
var attr = this.ownerDocument.createAttributeNS(namespaceURI, qualifiedName);
attr.value = attr.nodeValue = "" + value;
this.setAttributeNode(attr);
},
getAttributeNodeNS : function(namespaceURI, localName){
return this.attributes.getNamedItemNS(namespaceURI, localName);
},
getElementsByTagName : function(tagName){
return new LiveNodeList(this,function(base){
var ls = [];
_visitNode(base,function(node){
if(node !== base && node.nodeType == ELEMENT_NODE$3 && (tagName === '*' || node.tagName == tagName)){
ls.push(node);
}
});
return ls;
});
},
getElementsByTagNameNS : function(namespaceURI, localName){
return new LiveNodeList(this,function(base){
var ls = [];
_visitNode(base,function(node){
if(node !== base && node.nodeType === ELEMENT_NODE$3 && (namespaceURI === '*' || node.namespaceURI === namespaceURI) && (localName === '*' || node.localName == localName)){
ls.push(node);
}
});
return ls;
});
}
};
Document.prototype.getElementsByTagName = Element$1.prototype.getElementsByTagName;
Document.prototype.getElementsByTagNameNS = Element$1.prototype.getElementsByTagNameNS;
_extends(Element$1,Node$1);
function Attr() {
}Attr.prototype.nodeType = ATTRIBUTE_NODE;
_extends(Attr,Node$1);
function CharacterData() {
}CharacterData.prototype = {
data : '',
substringData : function(offset, count) {
return this.data.substring(offset, offset+count);
},
appendData: function(text) {
text = this.data+text;
this.nodeValue = this.data = text;
this.length = text.length;
},
insertData: function(offset,text) {
this.replaceData(offset,0,text);
},
appendChild:function(newChild){
throw new Error(ExceptionMessage[HIERARCHY_REQUEST_ERR])
},
deleteData: function(offset, count) {
this.replaceData(offset,count,"");
},
replaceData: function(offset, count, text) {
var start = this.data.substring(0,offset);
var end = this.data.substring(offset+count);
text = start + text + end;
this.nodeValue = this.data = text;
this.length = text.length;
}
};
_extends(CharacterData,Node$1);
function Text() {
}Text.prototype = {
nodeName : "#text",
nodeType : TEXT_NODE$2,
splitText : function(offset) {
var text = this.data;
var newText = text.substring(offset);
text = text.substring(0, offset);
this.data = this.nodeValue = text;
this.length = text.length;
var newNode = this.ownerDocument.createTextNode(newText);
if(this.parentNode){
this.parentNode.insertBefore(newNode, this.nextSibling);
}
return newNode;
}
};
_extends(Text,CharacterData);
function Comment() {
}Comment.prototype = {
nodeName : "#comment",
nodeType : COMMENT_NODE
};
_extends(Comment,CharacterData);
function CDATASection() {
}CDATASection.prototype = {
nodeName : "#cdata-section",
nodeType : CDATA_SECTION_NODE
};
_extends(CDATASection,CharacterData);
function DocumentType() {
}DocumentType.prototype.nodeType = DOCUMENT_TYPE_NODE;
_extends(DocumentType,Node$1);
function Notation() {
}Notation.prototype.nodeType = NOTATION_NODE;
_extends(Notation,Node$1);
function Entity() {
}Entity.prototype.nodeType = ENTITY_NODE;
_extends(Entity,Node$1);
function EntityReference() {
}EntityReference.prototype.nodeType = ENTITY_REFERENCE_NODE;
_extends(EntityReference,Node$1);
function DocumentFragment() {
}DocumentFragment.prototype.nodeName = "#document-fragment";
DocumentFragment.prototype.nodeType = DOCUMENT_FRAGMENT_NODE;
_extends(DocumentFragment,Node$1);
function ProcessingInstruction() {
}
ProcessingInstruction.prototype.nodeType = PROCESSING_INSTRUCTION_NODE;
_extends(ProcessingInstruction,Node$1);
function XMLSerializer$1(){}
XMLSerializer$1.prototype.serializeToString = function(node,isHtml,nodeFilter){
return nodeSerializeToString.call(node,isHtml,nodeFilter);
};
Node$1.prototype.toString = nodeSerializeToString;
function nodeSerializeToString(isHtml,nodeFilter){
var buf = [];
var refNode = this.nodeType == 9 && this.documentElement || this;
var prefix = refNode.prefix;
var uri = refNode.namespaceURI;
if(uri && prefix == null){
var prefix = refNode.lookupPrefix(uri);
if(prefix == null){
var visibleNamespaces=[
{namespace:uri,prefix:null}
];
}
}
serializeToString(this,buf,isHtml,nodeFilter,visibleNamespaces);
return buf.join('');
}
function needNamespaceDefine(node, isHTML, visibleNamespaces) {
var prefix = node.prefix || '';
var uri = node.namespaceURI;
if (!uri) {
return false;
}
if (prefix === "xml" && uri === NAMESPACE$2.XML || uri === NAMESPACE$2.XMLNS) {
return false;
}
var i = visibleNamespaces.length;
while (i--) {
var ns = visibleNamespaces[i];
if (ns.prefix === prefix) {
return ns.namespace !== uri;
}
}
return true;
}
function addSerializedAttribute(buf, qualifiedName, value) {
buf.push(' ', qualifiedName, '="', value.replace(/[<&"]/g,_xmlEncoder), '"');
}
function serializeToString(node,buf,isHTML,nodeFilter,visibleNamespaces){
if (!visibleNamespaces) {
visibleNamespaces = [];
}
if(nodeFilter){
node = nodeFilter(node);
if(node){
if(typeof node == 'string'){
buf.push(node);
return;
}
}else {
return;
}
}
switch(node.nodeType){
case ELEMENT_NODE$3:
var attrs = node.attributes;
var len = attrs.length;
var child = node.firstChild;
var nodeName = node.tagName;
isHTML = NAMESPACE$2.isHTML(node.namespaceURI) || isHTML;
var prefixedNodeName = nodeName;
if (!isHTML && !node.prefix && node.namespaceURI) {
var defaultNS;
for (var ai = 0; ai < attrs.length; ai++) {
if (attrs.item(ai).name === 'xmlns') {
defaultNS = attrs.item(ai).value;
break
}
}
if (!defaultNS) {
for (var nsi = visibleNamespaces.length - 1; nsi >= 0; nsi--) {
var namespace = visibleNamespaces[nsi];
if (namespace.prefix === '' && namespace.namespace === node.namespaceURI) {
defaultNS = namespace.namespace;
break
}
}
}
if (defaultNS !== node.namespaceURI) {
for (var nsi = visibleNamespaces.length - 1; nsi >= 0; nsi--) {
var namespace = visibleNamespaces[nsi];
if (namespace.namespace === node.namespaceURI) {
if (namespace.prefix) {
prefixedNodeName = namespace.prefix + ':' + nodeName;
}
break
}
}
}
}
buf.push('<', prefixedNodeName);
for(var i=0;i<len;i++){
var attr = attrs.item(i);
if (attr.prefix == 'xmlns') {
visibleNamespaces.push({ prefix: attr.localName, namespace: attr.value });
}else if(attr.nodeName == 'xmlns'){
visibleNamespaces.push({ prefix: '', namespace: attr.value });
}
}
for(var i=0;i<len;i++){
var attr = attrs.item(i);
if (needNamespaceDefine(attr,isHTML, visibleNamespaces)) {
var prefix = attr.prefix||'';
var uri = attr.namespaceURI;
addSerializedAttribute(buf, prefix ? 'xmlns:' + prefix : "xmlns", uri);
visibleNamespaces.push({ prefix: prefix, namespace:uri });
}
serializeToString(attr,buf,isHTML,nodeFilter,visibleNamespaces);
}
if (nodeName === prefixedNodeName && needNamespaceDefine(node, isHTML, visibleNamespaces)) {
var prefix = node.prefix||'';
var uri = node.namespaceURI;
addSerializedAttribute(buf, prefix ? 'xmlns:' + prefix : "xmlns", uri);
visibleNamespaces.push({ prefix: prefix, namespace:uri });
}
if(child || isHTML && !/^(?:meta|link|img|br|hr|input)$/i.test(nodeName)){
buf.push('>');
if(isHTML && /^script$/i.test(nodeName)){
while(child){
if(child.data){
buf.push(child.data);
}else {
serializeToString(child, buf, isHTML, nodeFilter, visibleNamespaces.slice());
}
child = child.nextSibling;
}
}else
{
while(child){
serializeToString(child, buf, isHTML, nodeFilter, visibleNamespaces.slice());
child = child.nextSibling;
}
}
buf.push('</',prefixedNodeName,'>');
}else {
buf.push('/>');
}
return;
case DOCUMENT_NODE$1:
case DOCUMENT_FRAGMENT_NODE:
var child = node.firstChild;
while(child){
serializeToString(child, buf, isHTML, nodeFilter, visibleNamespaces.slice());
child = child.nextSibling;
}
return;
case ATTRIBUTE_NODE:
return addSerializedAttribute(buf, node.name, node.value);
case TEXT_NODE$2:
return buf.push(node.data
.replace(/[<&]/g,_xmlEncoder)
.replace(/]]>/g, ']]>')
);
case CDATA_SECTION_NODE:
return buf.push( '<![CDATA[',node.data,']]>');
case COMMENT_NODE:
return buf.push( "<!--",node.data,"-->");
case DOCUMENT_TYPE_NODE:
var pubid = node.publicId;
var sysid = node.systemId;
buf.push('<!DOCTYPE ',node.name);
if(pubid){
buf.push(' PUBLIC ', pubid);
if (sysid && sysid!='.') {
buf.push(' ', sysid);
}
buf.push('>');
}else if(sysid && sysid!='.'){
buf.push(' SYSTEM ', sysid, '>');
}else {
var sub = node.internalSubset;
if(sub){
buf.push(" [",sub,"]");
}
buf.push(">");
}
return;
case PROCESSING_INSTRUCTION_NODE:
return buf.push( "<?",node.target," ",node.data,"?>");
case ENTITY_REFERENCE_NODE:
return buf.push( '&',node.nodeName,';');
default:
buf.push('??',node.nodeName);
}
}
function importNode(doc,node,deep){
var node2;
switch (node.nodeType) {
case ELEMENT_NODE$3:
node2 = node.cloneNode(false);
node2.ownerDocument = doc;
case DOCUMENT_FRAGMENT_NODE:
break;
case ATTRIBUTE_NODE:
deep = true;
break;
}
if(!node2){
node2 = node.cloneNode(false);
}
node2.ownerDocument = doc;
node2.parentNode = null;
if(deep){
var child = node.firstChild;
while(child){
node2.appendChild(importNode(doc,child,deep));
child = child.nextSibling;
}
}
return node2;
}
function cloneNode(doc,node,deep){
var node2 = new node.constructor();
for (var n in node) {
if (Object.prototype.hasOwnProperty.call(node, n)) {
var v = node[n];
if (typeof v != "object") {
if (v != node2[n]) {
node2[n] = v;
}
}
}
}
if(node.childNodes){
node2.childNodes = new NodeList();
}
node2.ownerDocument = doc;
switch (node2.nodeType) {