//--------------------------------------
//               PowerUI
//
//        For documentation or 
//    if you have any issues, visit
//        powerUI.kulestar.com
//
//    Copyright  2013 Kulestar Ltd
//          www.kulestar.com
//--------------------------------------

using System;
using Dom;


namespace Dom{
	
	/// <summary>
	/// Handles various standard attribute DOM functions.
	/// </summary>

	public partial class Node{
		
		/// <summary>Get the value of an attribute by name.</summary>
		public string getAttributeNS(string ns,string name){
			string result=null;
			Properties.TryGetValue(ns+":"+name,out result);
			return result;
		}
		
		/// <summary>Does this element have the named attribute?</summary>
		public bool hasAttributeNS(string ns,string name){
			return Properties.ContainsKey(ns+":"+name);
		}
		
		/// <summary>Set the named attribute.</summary>
		public void setAttributeNS(string ns,string name,string value){
			setAttribute(ns+":"+name,value);
		}
		
		/// <summary>Remove the named attribute.</summary>
		public void removeAttributeNS(string ns,string name){
			Properties.Remove(ns+":"+name);
		}
		
		/// <summary>Get the value of an attribute by name.</summary>
		public string getAttribute(string name){
			string result=null;
			Properties.TryGetValue(name,out result);
			return result;
		}
		
		/// <summary>Does this element have the named attribute?</summary>
		public bool hasAttribute(string name){
			return Properties.ContainsKey(name);
		}
		
		/// <summary>Set the named attribute.</summary>
		public void setAttribute(string name,string value){
			// Did it change?
			string before;
			Properties.TryGetValue(name, out before);
			Properties[name]=value;
			if(before!=value){
				// Sure did!
				OnAttributeChange(name);
			}
		}
		
		/// <summary>Remove the named attribute.</summary>
		public void removeAttribute(string name){
			Properties.Remove(name);
		}
		
	}
	
}