New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

nut

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nut - npm Package Compare versions

Comparing version 0.1.8 to 0.1.9

53

ender.js

@@ -1,12 +0,43 @@

var nut=require('nut');
// inspired from https://github.com/ded/qwery/blob/master/src/ender.js
$._select=function(selectors,contexts){
// Selectors
if(typeof selectors=='string'){
return nut(selectors,contexts);
}
// Nodes
else{
return selectors;
}
};
(function(){
var nut=require('nut');
$._select=function(selectors,contexts){
// New element
if(selectors.match(/^\s*</)){
var tag=selectors.match(/^\s*<\s*([a-z]+)/i)[1],
nodeMap={
thead: 'table',
tbody: 'table',
tfoot: 'table',
tr: 'tbody',
th: 'tr',
td: 'tr',
fieldset: 'form',
option: 'select'
},
root=document.createElement(nodeMap[tag] || 'div'),
element,
elements=[],
i=-1;
root.innerHTML=selectors;
element=root.firstChild;
do{
element.nodeType==1 && elements.push(element);
}
while(element=element.nextSibling)
return elements;
}
// Selectors
else if(typeof selectors=='string'){
return nut(selectors,contexts);
}
// Nodes
else{
return selectors;
}
};
}());
/*
nut, the concise CSS selector engine
Version : 0.1.8
Author : Aurélien Delogu (dev@dreamysource.fr)
URL : https://github.com/pyrsmk/nut
License : MIT
Version: 0.1.9
Author: Aurélien Delogu (dev@dreamysource.fr)
Homepage: https://github.com/pyrsmk/nut
License: MIT
*/
!function(name,obj){
(function(name,obj){
if(typeof module!='undefined'){

@@ -18,26 +18,22 @@ module.exports=obj;

}('nut',function(){
/*
Get nodes corresponding to a class name (for IE<9)
Get all nodes
Parameters
string name : class name
object context : contextual node
string selector : a selector
context : a context
Return
array : found nodes
object : nodes
*/
function getNodesByClassName(name,context){
// Init vars
var nodes=[],
child,
i=-1;
// Browse children
while(child=context.childNodes[++i]){
// Match the class
if(child.className && child.className.match('\\b'+name+'\\b')){
nodes.push(child);
function getAllNodes(selector,context){
var node=context.firstChild,
nodes=[];
// Reduce
if(node){
do{
node.nodeType==1 && nodes.push(node);
}
// Get nodes from child's children
nodes=nodes.concat(getNodesByClassName(name,child));
while(node=node.nextSibling);
}

@@ -48,3 +44,3 @@ return nodes;

/*
Get nodes from an id selector
Get id node

@@ -58,3 +54,3 @@ Parameters

*/
function getNodesFromIdSelector(selector,context){
function getNodeFromIdSelector(selector,context){
return [document.getElementById(selector)];

@@ -64,22 +60,37 @@ }

/*
Get nodes from a class selector
Get nodes corresponding to a class name (for IE<9)
Parameters
string selector : a selector
context : a context
string name : class name
object context : contextual node
Return
object : nodes
array : found nodes
*/
function getNodesFromClassSelector(selector,context){
if(context.getElementsByClassName){
return context.getElementsByClassName(selector);
function getNodesByClassName(name,context){
// Init vars
var node=context.firstChild,
nodes=[],
elements;
// Browse children
if(node){
do{
if(node.nodeType==1){
// Match the class
if(node.className && node.className.match('\\b'+name+'\\b')){
nodes.push(node);
}
// Get nodes from node's children
if((elements=getNodesByClassName(name,node)).length){
nodes=nodes.concat(elements);
}
}
}
while(node=node.nextSibling);
}
else{
return getNodesByClassName(selector,context);
}
return nodes;
}
/*
Get all nodes
Get nodes from a class selector

@@ -93,13 +104,9 @@ Parameters

*/
function getAllNodes(selector,context){
var node,
nodes=[],
i=-1;
// Reduce
while(node=context.childNodes[++i]){
if(node.tagName){
nodes.push(node);
}
function getNodesFromClassSelector(selector,context){
if(!context.getElementsByClassName){
return context.getElementsByClassName(selector);
}
return nodes;
else{
return getNodesByClassName(selector,context);
}
}

@@ -170,3 +177,3 @@

selector=selector.substr(1);
getNodesFromSelector=getNodesFromIdSelector;
getNodesFromSelector=getNodeFromIdSelector;
}

@@ -208,2 +215,2 @@ // Class

}());
}()));
{
"name" : "nut",
"description" : "The concise CSS selector engine",
"version" : "0.1.8",
"version" : "0.1.9",
"author" : "Aurélien Delogu <pyrsmk@dreamysource.fr> (http://dreamysource.fr)",

@@ -6,0 +6,0 @@ "repository" : {

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