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

using System;

namespace Css{
	
	/// <summary>
	/// Describes if an elements parent matches a selector. Any parent (indirect too) is OK.
	/// <summary>

	public class ParentMatch:StructureMatcher{
		
		public override void MoveUpwards(CssEvent e){
			
			// Current node:
			Dom.Node node=e.CurrentNode;
			
			if(node!=null){
				
				e.CurrentNode=node.parentNode;
				
				if(e.CurrentNode is Dom.Document){
					e.CurrentNode=null;
				}
				
			}
			
		}
		
		/// <summary>This one can repeat - i.e. it'll keep moving through the structure until it nulls.</summary>
		public override bool Repeat{
			get{
				return true;
			}
		}
		
		public override string ToString(){
			return " ";
		}
		
	}
	
}