Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

elements

Package Overview
Dependencies
Maintainers
2
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

elements - npm Package Compare versions

Comparing version 0.3.1 to 0.4.0

2

delegation.js

@@ -25,3 +25,3 @@ /*

var action = function(e){
var target = $(e.target),
var target = $(e.target || e.srcElement),
match = target.matches(selector) ? target : target.parent(selector)

@@ -28,0 +28,0 @@

{
"name": "elements",
"description": "prime dom library",
"version": "0.3.1",
"version": "0.4.0",
"license": "MIT (http://mootools.net/license.txt)",

@@ -6,0 +6,0 @@ "main": "./index.js",

@@ -1,8 +0,50 @@

elements
========
# ![elements](http://kamicane.github.io/assets/elements.png)
elements is a minimal DOM Library built on top of [prime](https://github.com/mootools/prime).
[![Build Status](http://img.shields.io/travis/kamicane/prime/master.svg)](http://travis-ci.org/kamicane/elements)
Read the [documentation](https://github.com/mootools/elements/blob/master/doc/elements.md).
A minimal DOM Library built on top of [prime](https://github.com/mootools/prime).
[![Build Status](https://secure.travis-ci.org/mootools/elements.png?branch=master)](http://travis-ci.org/mootools/elements)
## Overview
```js
// require elements
var $ = require('elements');
// require elements utilities
var ready = require('elements/domready');
var zen = require('elements/zen');
// do this on domready
ready(function() {
// create an element with css syntax
var element = zen('div#someID.className');
// add text and insert into body
element.text('read the documentation').insert(document.body);
// add an event listener for click
element.on('click', function() {
console.log('clicked!');
});
var document = $(document);
// find the element in the dom, it's the same elements instance!
if (document.find('div#someID.className') === element) {
console.log('success!');
}
// delegate click, because delegation is best
document.delegate('click', 'div#someID', function() {
console.log('delegation is nice');
});
// finally add a class name
element.addClass('className2');
});
```
When all else fails, read the [full documentation](https://github.com/mootools/elements/blob/master/doc/elements.md).

@@ -11,16 +11,10 @@ /*

var walk = function(combinator, method){
var gen = function(combinator, expression){
return map(slick.parse(expression || "*"), function(part){
return combinator + " " + part
}).join(", ")
}
return function(expression){
var parts = slick.parse(expression || "*")
var push_ = Array.prototype.push
expression = map(parts, function(part){
return combinator + " " + part
}).join(", ")
return this[method](expression)
}
}
$.implement({

@@ -32,4 +26,5 @@

var buffer = []
for (var i = 0, node; node = this[i]; i++) buffer.push.apply(buffer, slick.search(expression, node))
return $(buffer).sort()
for (var i = 0, node; node = this[i]; i++) push_.apply(buffer, slick.search(expression, node))
buffer = $(buffer)
return buffer && buffer.sort()
},

@@ -40,5 +35,8 @@

var buffer = []
for (var i = 0, node; node = this[i]; i++) buffer.push(slick.find(expression, node))
return $(buffer)
for (var i = 0, node; node = this[i]; i++) {
var found = slick.find(expression, node)
if (found) return $(found)
}
return null
},

@@ -58,19 +56,49 @@

nextSiblings: walk("~", "search"),
nextSiblings: function(expression){
return this.search(gen('~', expression))
},
nextSibling: walk("+", "find"),
nextSibling: function(expression){
return this.find(gen('+', expression))
},
previousSiblings: walk("!~", "search"),
previousSiblings: function(expression){
return this.search(gen('!~', expression))
},
previousSibling: walk("!+", "find"),
previousSibling: function(expression){
return this.find(gen('!+', expression))
},
children: walk(">", "search"),
children: function(expression){
return this.search(gen('>', expression))
},
firstChild: walk("^", "find"),
firstChild: function(expression){
return this.find(gen('^', expression))
},
lastChild: walk("!^", "find"),
lastChild: function(expression){
return this.find(gen('!^', expression))
},
parent: walk("!", "find"),
parent: function(expression){
var buffer = []
loop: for (var i = 0, node; node = this[i]; i++) while ((node = node.parentNode) && (node !== document)){
if (!expression || slick.matches(node, expression)){
buffer.push(node)
break loop
break
}
}
return $(buffer)
},
parents: walk("!", "search")
parents: function(expression){
var buffer = []
for (var i = 0, node; node = this[i]; i++) while ((node = node.parentNode) && (node !== document)){
if (!expression || slick.matches(node, expression)) buffer.push(node)
}
return $(buffer)
}

@@ -77,0 +105,0 @@ })

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc