dom-conform

2.0.1 • Public • Published

dom-conform

Resolve and find element class names

Concept

//Add "hello" to the element class list.
conform(element, "hello", true);

//Remove "hello" from the element class list.
conform(element, "hello", false);

//Determine whether the element class list contains "hello"
conform(element, "hello");
//Return the first child of element conforming to "world"
conform.find(element, "world");

//Run the callback function on each child of element conforming to "world"
conform.find(element, "world", callback);
//Return the first parent of element conforming to "world"
conform.closest(element, "world");

Examples

var submit = function() {
	//Mark the form as "invalid"
	conform(form, "invalid", true);
}
var layout = function() {
	//Run the specified function on conforming childs
	conform.find(element, "aspect-fill", function(child){
		//Calculate ratio and update child geometric style properties.
	});
}
var menuClickHandler = function(event) {
	//Get the menu item of the clicked target
	var item = conform.closest(event.target, "menu-item");
}

Readme

Keywords

Package Sidebar

Install

npm i dom-conform

Weekly Downloads

1

Version

2.0.1

License

MIT

Last publish

Collaborators

  • samuelpetersson