/
nns.min.js
4 lines (4 loc) · 1.92 KB
/
nns.min.js
1
2
3
4
(function(g){function h(a){if(/^#/.test(a))return document.getElementById(a.substring(1));a=i(a);return a.space==null?document.createElement(a.local):document.createElementNS(a.space,a.local)}function i(a){var b=a.indexOf(":");return{space:d.prefix[a.substring(0,b)],local:a.substring(b+1)}}function j(a){this.element=a}function d(a){return a==null||a.element?a:new j(typeof a=="string"?h(a):a)}function e(a){return a&&a.element||a}j.prototype={add:function(a,b){return d(this.element.insertBefore(typeof a==
"string"?h(a):e(a),arguments.length==1?null:e(b)))},remove:function(a){this.element.removeChild(e(a));return this},parent:function(){return d(this.element.parentNode)},child:function(a){var b=this.element.childNodes;return d(b[a<0?b.length-a-1:a])},previous:function(){return d(this.element.previousSibling)},next:function(){return d(this.element.nextSibling)},attr:function(a,b){var c=this.element;a=i(a);if(arguments.length==1)return a.space==null?c.getAttribute(a.local):c.getAttributeNS(a.space,a.local);
if(a.space==null)b==null?c.removeAttribute(a.local):c.setAttribute(a.local,b);else b==null?c.removeAttributeNS(a.space,a.local):c.setAttributeNS(a.space,a.local,b);return this},style:function(a,b,c){var f=this.element.style;if(arguments.length==1)return f.getPropertyValue(a);b==null?f.removeProperty(a):f.setProperty(a,b,arguments.length==3?c:null);return this},on:function(a,b,c){this.element.addEventListener(a,b,arguments.length==3?c:false);return this},off:function(a,b,c){this.element.removeEventListener(a,
b,arguments.length==3?c:false);return this},text:function(a){var b=this.element.firstChild;if(!arguments.length)return b&&b.nodeValue;if(b)b.nodeValue=a;else a!=null&&this.element.appendChild(document.createTextNode(a));return this}};d.prefix={svg:"http://www.w3.org/2000/svg",xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};d.version="1.1.0";g.n$=d;g.$n=e})(this);