Comparing version 0.0.2 to 0.0.3
var fs = require( 'fs' ), | ||
async = require( 'async' ), | ||
libs = require( './libs.js' ), | ||
StringIterator = require( "string-iterator" ), | ||
ROOT_DIR = __dirname + '/../', | ||
@@ -9,6 +10,13 @@ LIB_DIR = ROOT_DIR + 'lib/', | ||
libs.unshift( 'headers.txt', 'CSSTree.js' ); | ||
libs.unshift( StringIterator ); | ||
async.map( libs, | ||
function( file, callback ) { | ||
fs.readFile( ( file == 'headers.txt' ? __dirname + '/' : LIB_DIR ) + file, 'utf8', callback ); | ||
if ( file === StringIterator ) { | ||
StringIterator.exportScript( callback ); | ||
} | ||
else { | ||
fs.readFile( ( file == 'headers.txt' ? __dirname + '/' : LIB_DIR ) + file, 'utf8', callback ); | ||
} | ||
}, | ||
@@ -20,3 +28,3 @@ function( e, results ) { | ||
var contents = results.shift(); | ||
var contents = results.shift() + results.shift(); | ||
while ( results.length ) { | ||
@@ -23,0 +31,0 @@ contents += "(function( global, undefined ) {\n\n" + |
/* | ||
* CSSTree 0.0.2 | ||
* CSSTree 0.0.3 | ||
* Corey Hart @ http://www.codenothing.com | ||
* MIT License http://www.codenothing.com/license | ||
*/ |
@@ -1,2 +0,1 @@ | ||
var CSSTree = global.CSSTree = require( '../' ); | ||
var munit = global.munit = require( 'munit' ); | ||
@@ -11,4 +10,3 @@ | ||
munit.render( __dirname + '/../test/', { | ||
junit: __dirname + '/results/', | ||
junitPrefix: process.version.replace( /\./g, '_' ) | ||
results: __dirname + '/results/' | ||
}); |
@@ -0,1 +1,6 @@ | ||
## v0.0.3 | ||
Installed StringIterator utility to replace manual loops | ||
## v0.0.2 | ||
@@ -2,0 +7,0 @@ |
@@ -71,3 +71,3 @@ window.jQuery(function( jQuery ) { | ||
parseInt( selectStart.val() || '0', 10 ), | ||
parseInt( selectEnd.val() || '0', 10 ) | ||
parseInt( selectEnd.val() || '0', 10 ) + 1 | ||
); | ||
@@ -74,0 +74,0 @@ |
@@ -30,3 +30,3 @@ window.jQuery(function( jQuery ) { | ||
if ( branch.branches && branch.branches.length ) { | ||
insertLinks( branches ); | ||
insertLinks( branch.branches ); | ||
} | ||
@@ -78,3 +78,3 @@ }); | ||
start = parseInt( parts[ 0 ] || '', 10 ), | ||
end = parseInt( parts[ 1 ] || '', 10 ); | ||
end = parseInt( parts[ 1 ] || '', 10 ) + 1; | ||
@@ -81,0 +81,0 @@ if ( end > start ) { |
var fs = require( 'fs' ), | ||
_CSSTree = global.CSSTree; | ||
_CSSTree = global.CSSTree, | ||
_StringIterator = global.StringIterator; | ||
// Grab CSSTree files | ||
global.StringIterator = require( "string-iterator" ); | ||
global.CSSTree = module.exports = require( './lib/CSSTree.js' ); | ||
@@ -24,2 +26,3 @@ require( './build/libs.js' ).forEach(function( file ) { | ||
// Clear global case | ||
global.StringIterator = _StringIterator; | ||
global.CSSTree = _CSSTree; |
@@ -1,4 +0,4 @@ | ||
var rnewlineseek = /(\r\n|\r|\n)/g, | ||
rwhitespace = /(\s|\t|\r\n|\r|\n)/, | ||
leftTrim = /^(\r\n|\r|\n|\t|\s)*/; | ||
var rwhitespace = /(\s|\t|\r\n|\r|\n)/, | ||
leftTrim = /^(\r\n|\r|\n|\t|\s)*/, | ||
StringIterator = global.StringIterator; | ||
@@ -15,16 +15,8 @@ | ||
// Internals | ||
self.css = css || ''; | ||
self.i = -1; | ||
self.length = self.css.length; | ||
self.iter = new StringIterator( css ); | ||
self.css = css; | ||
self.branches = []; | ||
// Positional setup | ||
self._newlines = []; | ||
while ( ( m = rnewlineseek.exec( self.css ) ) ) { | ||
self._newlines.push( rnewlineseek.lastIndex - 1 ); | ||
} | ||
// Begin rendering | ||
self.render(); | ||
self._positions( self.branches ); | ||
} | ||
@@ -37,23 +29,20 @@ | ||
render: function(){ | ||
var self = this, peek = ''; | ||
var self = this, | ||
iter = self.iter; | ||
for ( ; ++self.i < self.length; ) { | ||
self.c = self.css[ self.i ]; | ||
peek = self.css[ self.i + 1 ]; | ||
iter.each(function( c ) { | ||
// Comment | ||
if ( self.c == '/' && peek == '*' ) { | ||
self.i--; | ||
if ( c == '/' && iter.next == '*' ) { | ||
iter.reverse(); | ||
self.comment(); | ||
} | ||
// Skip over all whitespace | ||
else if ( rwhitespace.exec( self.c ) ) { | ||
continue; | ||
} | ||
// Assume anything else is a selector/atrule | ||
else { | ||
self.i--; | ||
// Skip over whitespace, but assume anything else is a selector/atrule | ||
else if ( ! rwhitespace.exec( c ) ) { | ||
iter.reverse(); | ||
self.selector(); | ||
} | ||
} | ||
}); | ||
// Apply line/character information to all positions | ||
self._positions( self.branches ); | ||
}, | ||
@@ -64,21 +53,13 @@ | ||
var self = this, | ||
position = new CSSTree.Position( self.i + 1 ), | ||
comment = '', | ||
peek = ''; | ||
iter = self.iter, | ||
position = new CSSTree.Position( iter.index + 1 ), | ||
comment = iter.each(function( c, iter ) { | ||
if ( iter.c == '/' && iter.prev == '*' ) { | ||
return false; | ||
} | ||
}); | ||
nested = nested || false; | ||
for ( ; ++self.i < self.length; ) { | ||
self.c = self.css[ self.i ]; | ||
peek = self.css[ self.i + 1 ]; | ||
// End of comment | ||
if ( self.c == '*' && peek == '/' ) { | ||
return self.branches.push( | ||
new CSSTree.Comment( comment + '*/', nested, position.markEnd( ++self.i + 1 ) ) | ||
); | ||
} | ||
else { | ||
comment += self.c; | ||
} | ||
} | ||
self.branches.push( | ||
new CSSTree.Comment( comment, nested || false, position.markEnd( iter.index ) ) | ||
); | ||
}, | ||
@@ -89,59 +70,60 @@ | ||
var self = this, | ||
position = new CSSTree.Position( self.i + 1 ), | ||
iter = self.iter, | ||
position = new CSSTree.Position( iter.index + 1 ), | ||
selector = '', | ||
character, | ||
parts = [], nested = null, part = '', | ||
peek, branch; | ||
branch; | ||
for ( ; ++self.i < self.length; ) { | ||
self.c = self.css[ self.i ]; | ||
peek = self.css[ self.i + 1 ]; | ||
iter.each(function( c ) { | ||
// Comment block | ||
if ( self.c == '/' && peek == '*' ) { | ||
position.markChunkEnd( self.i-- ); | ||
if ( c == '/' && iter.next == '*' ) { | ||
iter.reverse(); | ||
position.markChunkEnd( iter.index ); | ||
self.comment(); | ||
position.markChunkStart( self.i + 1 ); | ||
position.markChunkStart( iter.index + 1 ); | ||
} | ||
// Atrule | ||
else if ( self.c == ';' ) { | ||
return self.branches.push( | ||
new CSSTree.AtRule( selector, position.markEnd( self.i ) ) | ||
); | ||
else if ( c == ';' ) { | ||
return false; | ||
} | ||
// Media atrule | ||
else if ( self.c == '{' && selector.trim()[ 0 ] == '@' ) { | ||
else if ( c == '{' && selector.trim()[ 0 ] == '@' ) { | ||
branch = self.nested( selector, position ); | ||
branch.position = position.markEnd( self.i + 1 ); | ||
return self.branches.push( branch ); | ||
branch.position = position.markEnd( iter.index ); | ||
self.branches.push( branch ); | ||
selector = null; | ||
return false; | ||
} | ||
// Selector for ruleset | ||
else if ( self.c == '{' ) { | ||
else if ( c == '{' ) { | ||
branch = new CSSTree.Selector( selector, self.rules( position ), position ); | ||
position.markEnd( self.i + 1 ); | ||
return self.branches.push( branch ); | ||
position.markEnd( iter.index ); | ||
self.branches.push( branch ); | ||
selector = null; | ||
return false; | ||
} | ||
// Escape string | ||
else if ( self.c == '\\' ) { | ||
selector += self.c + self.css[ ++self.i ]; | ||
else if ( c == "\\" ) { | ||
iter.skip(); | ||
selector += c + iter.c; | ||
} | ||
// Seek | ||
else if ( self.c == "'" || self.c == '"' ) { | ||
character = self.c; | ||
selector += character + self.find( character ) + character; | ||
else if ( c == "'" || c == '"' ) { | ||
selector += c + iter.seek( c ); | ||
} | ||
// Seek | ||
else if ( self.c == '(' ) { | ||
selector += '(' + self.find( ')' ) + ')'; | ||
else if ( c == '(' ) { | ||
selector += c + iter.seek( ')' ); | ||
} | ||
// Add to selector string | ||
else { | ||
selector += self.c; | ||
selector += c; | ||
} | ||
} | ||
}); | ||
// Catch end of file queries without semi-colon | ||
if ( selector.trim().length ) { | ||
return self.branches.push( | ||
new CSSTree.AtRule( selector, position.markEnd( self.i ) ) | ||
// Single line queries | ||
if ( selector && selector.trim().length ) { | ||
self.branches.push( | ||
new CSSTree.AtRule( selector, position.markEnd( iter.index - 1 ) ) | ||
); | ||
@@ -153,22 +135,24 @@ } | ||
rules: function( parentPos ) { | ||
var self = this, rules = [], peek, rule, position; | ||
var self = this, | ||
iter = self.iter, | ||
rules = [], | ||
rule, position; | ||
for ( ; ++self.i < self.length; ) { | ||
self.c = self.css[ self.i ]; | ||
peek = self.css[ self.i + 1 ]; | ||
// Comment | ||
if ( self.c == '/' && peek == '*' ) { | ||
parentPos.markChunkEnd( self.i-- ); | ||
iter.each(function( c ) { | ||
// Nested Comment block | ||
if ( c == '/' && iter.next == '*' ) { | ||
iter.reverse(); | ||
parentPos.markChunkEnd( iter.index ); | ||
self.comment( true ); | ||
parentPos.markChunkStart( self.i + 1 ); | ||
parentPos.markChunkStart( iter.index + 1 ); | ||
} | ||
// End of rules | ||
else if ( self.c == '}' ) { | ||
return rules; | ||
else if ( c == '}' ) { | ||
return false; | ||
} | ||
// New rule | ||
else if ( ! rwhitespace.exec( self.c ) ) { | ||
position = new CSSTree.Position( self.i, parentPos ); | ||
self.i--; | ||
else if ( ! rwhitespace.exec( c ) ) { | ||
position = new CSSTree.Position( iter.index, parentPos ); | ||
iter.reverse(); | ||
rule = new CSSTree.Rule( | ||
@@ -181,3 +165,3 @@ self.property( position ).trim(), | ||
// Break down the parts of the value, and push it | ||
position.markEnd( self.i, false ); | ||
position.markEnd( iter.index - ( iter.c == ';' ? 1 : 0 ), false ); | ||
@@ -189,3 +173,3 @@ // Only add if there is an actual property | ||
} | ||
} | ||
}); | ||
@@ -197,27 +181,27 @@ return rules; | ||
property: function( position ) { | ||
var self = this, property = '', peek; | ||
var self = this, | ||
iter = self.iter, | ||
property = ''; | ||
for ( ; ++self.i < self.length; ) { | ||
self.c = self.css[ self.i ]; | ||
peek = self.css[ self.i + 1 ]; | ||
// Nested Comment | ||
if ( self.c == '/' && peek == '*' ) { | ||
position.markChunkEnd( self.i-- ); | ||
iter.each(function( c ) { | ||
// Nested Comment block | ||
if ( c == '/' && iter.next == '*' ) { | ||
iter.reverse(); | ||
position.markChunkEnd( iter.index ); | ||
self.comment( true ); | ||
position.markChunkStart( self.i + 1 ); | ||
position.markChunkStart( iter.index + 1 ); | ||
} | ||
// End of property | ||
else if ( self.c == ':' ) { | ||
return property; | ||
else if ( c == ':' ) { | ||
return false; | ||
} | ||
// Invalid CSS, but still end of property | ||
else if ( self.c == ';' || self.c == '}' ) { | ||
self.i--; | ||
return property; | ||
else if ( c == ';' || c == '}' ) { | ||
iter.reverse(); | ||
return false; | ||
} | ||
else { | ||
property += self.c; | ||
property += c; | ||
} | ||
} | ||
}); | ||
@@ -229,37 +213,36 @@ return property; | ||
value: function( position ) { | ||
var self = this, value = '', character, peek; | ||
var self = this, | ||
iter = self.iter, | ||
value = ''; | ||
for ( ; ++self.i < self.length; ) { | ||
self.c = self.css[ self.i ]; | ||
peek = self.css[ self.i + 1 ]; | ||
// Comment | ||
if ( self.c == '/' && peek == '*' ) { | ||
position.markChunkEnd( self.i-- ); | ||
iter.each(function( c ) { | ||
// Nested Comment block | ||
if ( c == '/' && iter.next == '*' ) { | ||
iter.reverse(); | ||
position.markChunkEnd( iter.index ); | ||
self.comment( true ); | ||
position.markChunkStart( self.i + 1 ); | ||
position.markChunkStart( iter.index + 1 ); | ||
} | ||
// End of value | ||
else if ( self.c == ';' ) { | ||
return value; | ||
else if ( c == ';' ) { | ||
return false; | ||
} | ||
// Watch for no semi-colon at end of set | ||
else if ( self.c == '}' ) { | ||
self.i--; | ||
return value; | ||
else if ( c == '}' ) { | ||
iter.reverse(); | ||
return false; | ||
} | ||
// Seek strings | ||
else if ( self.c == "'" || self.c == '"' ) { | ||
character = self.c; | ||
value += character + self.find( character ) + character; | ||
else if ( c == "'" || c == '"' ) { | ||
value += c + iter.seek( c ); | ||
} | ||
// Seek groupings | ||
else if ( self.c == '(' ) { | ||
value += '(' + self.find( ')' ) + ')'; | ||
else if ( c == '(' ) { | ||
value += c + iter.seek( ')' ); | ||
} | ||
// Append | ||
else { | ||
value += self.c; | ||
value += c; | ||
} | ||
} | ||
}); | ||
@@ -269,29 +252,7 @@ return value; | ||
// Parsing through escapable content | ||
find: function( endstring ) { | ||
var self = this, string = ''; | ||
for ( ; ++self.i < self.length; ) { | ||
self.c = self.css[ self.i ]; | ||
// Escaped character | ||
if ( self.c == "\\" ) { | ||
string += self.c + self.css[ ++self.i ]; | ||
} | ||
// Seek charactor hit | ||
else if ( self.c == endstring ) { | ||
return string; | ||
} | ||
// Append | ||
else { | ||
string += self.c; | ||
} | ||
} | ||
return string; | ||
}, | ||
// Nested atrules | ||
nested: function( atrule, position ) { | ||
var self = this, | ||
iter = self.iter, | ||
startPos = null, | ||
string = '', | ||
@@ -303,16 +264,14 @@ peek, index, rule, subPosition, character, | ||
for ( ; ++self.i < self.length; ) { | ||
self.c = self.css[ self.i ]; | ||
peek = self.css[ self.i + 1 ]; | ||
// Comment | ||
if ( self.c == '/' && peek == '*' ) { | ||
position.markChunkEnd( self.i-- ); | ||
iter.each(function( c ) { | ||
// Nested Comment block | ||
if ( c == '/' && iter.next == '*' ) { | ||
iter.reverse(); | ||
position.markChunkEnd( iter.index ); | ||
self.comment( true ); | ||
position.markChunkStart( self.i + 1 ); | ||
position.markChunkStart( iter.index ); | ||
} | ||
// End of property:value | ||
else if ( self.c == ';' ) { | ||
subPosition = new CSSTree.Position( self.i - string.trim().length ); | ||
subPosition.markEnd( self.i ); | ||
else if ( c == ';' ) { | ||
subPosition = new CSSTree.Position( startPos ); | ||
subPosition.markEnd( iter.index - ( iter.c == ';' ? 1 : 0 ) ); | ||
@@ -337,6 +296,7 @@ // String trimming & positioning | ||
block.rules.push( rule ); | ||
startPos = null; | ||
string = ''; | ||
} | ||
// Nested Block | ||
else if ( self.c == '{' ) { | ||
else if ( c == '{' ) { | ||
if ( ! block.branches ) { | ||
@@ -350,18 +310,18 @@ block.branches = []; | ||
// Travel down the tree | ||
subPosition = new CSSTree.Position( self.i - string.length, position ); | ||
subPosition = new CSSTree.Position( startPos, position ); | ||
block.branches.push( self.nested( string, subPosition ) ); | ||
startPos = null; | ||
string = ''; | ||
} | ||
// Seek | ||
else if ( self.c == "'" || self.c == '"' ) { | ||
character = self.c; | ||
string += character + self.find( character ) + character; | ||
else if ( c == "'" || c == '"' ) { | ||
string += c + iter.seek( c ); | ||
} | ||
// Seek | ||
else if ( self.c == '(' ) { | ||
string += '(' + self.find( ')' ) + ')'; | ||
else if ( c == '(' ) { | ||
string += c + iter.seek( ')' ); | ||
} | ||
// End of block | ||
else if ( self.c == '}' ) { | ||
subPosition = new CSSTree.Position( self.i - string.length ); | ||
else if ( c == '}' ) { | ||
subPosition = new CSSTree.Position( startPos ); | ||
@@ -374,3 +334,3 @@ // Assume any string left is a property:value definition | ||
string.substr( index + 1 ).trim(), | ||
subPosition.markEnd( self.i ) | ||
subPosition.markEnd( iter.index - 1 ) | ||
); | ||
@@ -387,10 +347,14 @@ | ||
block.position.markEnd( self.i + 1, false ); | ||
return block; | ||
block.position.markEnd( iter.index, false ); | ||
return false; | ||
} | ||
// Append | ||
else { | ||
string += self.c; | ||
if ( startPos === null && ! rwhitespace.exec( c ) ) { | ||
startPos = iter.index; | ||
} | ||
string += c; | ||
} | ||
} | ||
}); | ||
@@ -435,14 +399,8 @@ return block; | ||
_charPosition: function( pos ) { | ||
var self = this, line = self._newlines.length, character = 0; | ||
var self = this, | ||
iter = self.iter.goto( pos ); | ||
while ( line-- ) { | ||
if ( pos > self._newlines[ line ] ) { | ||
character = self._newlines[ line ] + 1; | ||
break; | ||
} | ||
} | ||
return { | ||
line: line + 2, | ||
character: ( pos + 1 ) - character | ||
line: iter.line, | ||
character: iter.character | ||
}; | ||
@@ -453,2 +411,4 @@ } | ||
// Keep Reference | ||
CSSTree.StringIterator = StringIterator; | ||
@@ -455,0 +415,0 @@ // Expose to NodeJS/Window |
@@ -41,3 +41,3 @@ function Position( start, _parent ) { | ||
self._chunk.end = pos; | ||
self._chunk.length = pos - self._chunk.start; | ||
self._chunk.length = pos - self._chunk.start + 1; | ||
delete self._chunk; | ||
@@ -58,3 +58,3 @@ } | ||
self.range.end = pos; | ||
self.range.length = pos - self.range.start; | ||
self.range.length = pos - self.range.start + 1; | ||
@@ -61,0 +61,0 @@ if ( self._parent ) { |
{ | ||
"name": "csstree", | ||
"description": "CSS to javascript object parser", | ||
"repository": "https://github.com/codenothing/CSSTree/", | ||
"keywords": [ "css", "parser", "tool" ], | ||
"version": "0.0.3", | ||
"main": "./index.js", | ||
"description": "CSS AST Builder", | ||
"keywords": [ "css", "parser", "tool", "ast" ], | ||
"author": "Corey Hart <corey@codenothing.com> (http://www.codenothing.com)", | ||
"homepage": "http://codenothing.github.com/CSSTree/", | ||
"version": "0.0.2", | ||
"main": "./index.js", | ||
"license": "MIT", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/codenothing/CSSTree.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/codenothing/CSSTree/issues", | ||
"email": "corey@codenothing.com" | ||
}, | ||
"engines": { | ||
@@ -14,11 +22,13 @@ "node": ">=0.8" | ||
"scripts": { | ||
"test": "make test" | ||
"test": "make test", | ||
"postinstall": "node build/build.js" | ||
}, | ||
"dependencies": { | ||
"string-iterator": "0.0.1" | ||
}, | ||
"devDependencies": { | ||
"nlint": "0.0.4", | ||
"munit": "0.0.5", | ||
"nlint": "0.0.6", | ||
"munit": "0.0.7", | ||
"async": "0.2.9" | ||
} | ||
} |
# CSSTree | ||
CSS parsing into javascript object. | ||
CSS AST Builder | ||
@@ -106,6 +106,6 @@ [![Build Status](https://travis-ci.org/codenothing/CSSTree.png?branch=master)](https://travis-ci.org/codenothing/CSSTree) | ||
* **range**: Contains the start and end positions of the fragment within the stylesheet | ||
* **range**: Contains the start and end indexes of the fragment within the stylesheet | ||
* **start**: Contains the starting line/character info of the fragment based on line breaks (\r\n|\r|\n) | ||
* **end**: Contains the ending line/character info of the fragment based on line breaks (\r\n|\r|\n) | ||
* **chunks**: When a comment exists between the start & end positions, chunks represents only the sections that belong to this position. | ||
* **chunks**: When a comment exists between the start & end indexes, chunks represents only the sections that belong to this position. | ||
@@ -112,0 +112,0 @@ |
@@ -8,3 +8,3 @@ module.exports = [ | ||
start: 0, | ||
end: 102, | ||
end: 101, | ||
length: 102 | ||
@@ -18,3 +18,3 @@ }, | ||
line: 5, | ||
character: 3 | ||
character: 2 | ||
}, | ||
@@ -24,3 +24,3 @@ chunks: [ | ||
start: 0, | ||
end: 102, | ||
end: 101, | ||
length: 102 | ||
@@ -37,3 +37,3 @@ } | ||
start: 142, | ||
end: 150, | ||
end: 149, | ||
length: 8 | ||
@@ -47,3 +47,3 @@ }, | ||
line: 7, | ||
character: 24 | ||
character: 23 | ||
}, | ||
@@ -53,3 +53,3 @@ chunks: [ | ||
start: 142, | ||
end: 150, | ||
end: 149, | ||
length: 8 | ||
@@ -66,3 +66,3 @@ } | ||
start: 214, | ||
end: 226, | ||
end: 225, | ||
length: 12 | ||
@@ -76,3 +76,3 @@ }, | ||
line: 10, | ||
character: 28 | ||
character: 27 | ||
}, | ||
@@ -82,3 +82,3 @@ chunks: [ | ||
start: 214, | ||
end: 226, | ||
end: 225, | ||
length: 12 | ||
@@ -102,4 +102,4 @@ } | ||
start: 103, | ||
end: 228, | ||
length: 125 | ||
end: 227, | ||
length: 125 | ||
}, | ||
@@ -112,3 +112,3 @@ start: { | ||
line: 11, | ||
character: 2 | ||
character: 1 | ||
}, | ||
@@ -118,3 +118,3 @@ chunks: [ | ||
start: 103, | ||
end: 142, | ||
end: 141, | ||
length: 39 | ||
@@ -124,3 +124,3 @@ }, | ||
start: 150, | ||
end: 214, | ||
end: 213, | ||
length: 64 | ||
@@ -130,3 +130,3 @@ }, | ||
start: 226, | ||
end: 228, | ||
end: 227, | ||
length: 2 | ||
@@ -144,3 +144,3 @@ } | ||
start: 128, | ||
end: 140, | ||
end: 139, | ||
length: 12 | ||
@@ -154,3 +154,3 @@ }, | ||
line: 7, | ||
character: 14 | ||
character: 13 | ||
}, | ||
@@ -160,3 +160,3 @@ chunks: [ | ||
start: 128, | ||
end: 140, | ||
end: 139, | ||
length: 12 | ||
@@ -174,3 +174,3 @@ } | ||
start: 152, | ||
end: 173, | ||
end: 172, | ||
length: 21 | ||
@@ -184,3 +184,3 @@ }, | ||
line: 8, | ||
character: 23 | ||
character: 22 | ||
}, | ||
@@ -190,3 +190,3 @@ chunks: [ | ||
start: 152, | ||
end: 173, | ||
end: 172, | ||
length: 21 | ||
@@ -204,3 +204,3 @@ } | ||
start: 176, | ||
end: 197, | ||
end: 196, | ||
length: 21 | ||
@@ -214,3 +214,3 @@ }, | ||
line: 9, | ||
character: 23 | ||
character: 22 | ||
}, | ||
@@ -220,3 +220,3 @@ chunks: [ | ||
start: 176, | ||
end: 197, | ||
end: 196, | ||
length: 21 | ||
@@ -234,3 +234,3 @@ } | ||
start: 200, | ||
end: 212, | ||
end: 211, | ||
length: 12 | ||
@@ -244,3 +244,3 @@ }, | ||
line: 10, | ||
character: 14 | ||
character: 13 | ||
}, | ||
@@ -250,3 +250,3 @@ chunks: [ | ||
start: 200, | ||
end: 212, | ||
end: 211, | ||
length: 12 | ||
@@ -265,3 +265,3 @@ } | ||
start: 265, | ||
end: 277, | ||
end: 276, | ||
length: 12 | ||
@@ -275,3 +275,3 @@ }, | ||
line: 14, | ||
character: 28 | ||
character: 27 | ||
}, | ||
@@ -281,3 +281,3 @@ chunks: [ | ||
start: 265, | ||
end: 277, | ||
end: 276, | ||
length: 12 | ||
@@ -299,3 +299,3 @@ } | ||
start: 230, | ||
end: 279, | ||
end: 278, | ||
length: 49 | ||
@@ -309,3 +309,3 @@ }, | ||
line: 15, | ||
character: 2 | ||
character: 1 | ||
}, | ||
@@ -315,3 +315,3 @@ chunks: [ | ||
start: 230, | ||
end: 265, | ||
end: 264, | ||
length: 35 | ||
@@ -321,3 +321,3 @@ }, | ||
start: 277, | ||
end: 279, | ||
end: 278, | ||
length: 2 | ||
@@ -335,3 +335,3 @@ } | ||
start: 251, | ||
end: 263, | ||
end: 262, | ||
length: 12 | ||
@@ -345,3 +345,3 @@ }, | ||
line: 14, | ||
character: 14 | ||
character: 13 | ||
}, | ||
@@ -351,3 +351,3 @@ chunks: [ | ||
start: 251, | ||
end: 263, | ||
end: 262, | ||
length: 12 | ||
@@ -354,0 +354,0 @@ } |
@@ -1,2 +0,1 @@ | ||
module.exports = [ | ||
@@ -9,3 +8,3 @@ { | ||
start: 0, | ||
end: 22, | ||
end: 21, | ||
length: 22 | ||
@@ -19,3 +18,3 @@ }, | ||
line: 1, | ||
character: 23 | ||
character: 22 | ||
}, | ||
@@ -25,3 +24,3 @@ chunks: [ | ||
start: 0, | ||
end: 22, | ||
end: 21, | ||
length: 22 | ||
@@ -38,3 +37,3 @@ } | ||
start: 25, | ||
end: 57, | ||
end: 56, | ||
length: 32 | ||
@@ -48,3 +47,3 @@ }, | ||
line: 5, | ||
character: 2 | ||
character: 1 | ||
}, | ||
@@ -54,3 +53,3 @@ chunks: [ | ||
start: 25, | ||
end: 57, | ||
end: 56, | ||
length: 32 | ||
@@ -68,3 +67,3 @@ } | ||
start: 42, | ||
end: 54, | ||
end: 53, | ||
length: 12 | ||
@@ -78,3 +77,3 @@ }, | ||
line: 4, | ||
character: 14 | ||
character: 13 | ||
}, | ||
@@ -84,3 +83,3 @@ chunks: [ | ||
start: 42, | ||
end: 54, | ||
end: 53, | ||
length: 12 | ||
@@ -99,3 +98,3 @@ } | ||
start: 59, | ||
end: 224, | ||
end: 223, | ||
length: 165 | ||
@@ -109,3 +108,3 @@ }, | ||
line: 15, | ||
character: 2 | ||
character: 1 | ||
}, | ||
@@ -115,3 +114,3 @@ chunks: [ | ||
start: 59, | ||
end: 224, | ||
end: 223, | ||
length: 165 | ||
@@ -129,3 +128,3 @@ } | ||
start: 131, | ||
end: 143, | ||
end: 142, | ||
length: 12 | ||
@@ -139,3 +138,3 @@ }, | ||
line: 8, | ||
character: 14 | ||
character: 13 | ||
}, | ||
@@ -145,3 +144,3 @@ chunks: [ | ||
start: 131, | ||
end: 143, | ||
end: 142, | ||
length: 12 | ||
@@ -160,3 +159,3 @@ } | ||
start: 146, | ||
end: 222, | ||
end: 221, | ||
length: 76 | ||
@@ -170,3 +169,3 @@ }, | ||
line: 14, | ||
character: 3 | ||
character: 2 | ||
}, | ||
@@ -176,3 +175,3 @@ chunks: [ | ||
start: 146, | ||
end: 222, | ||
end: 221, | ||
length: 76 | ||
@@ -190,3 +189,3 @@ } | ||
start: 162, | ||
end: 174, | ||
end: 173, | ||
length: 12 | ||
@@ -200,3 +199,3 @@ }, | ||
line: 10, | ||
character: 15 | ||
character: 14 | ||
}, | ||
@@ -206,3 +205,3 @@ chunks: [ | ||
start: 162, | ||
end: 174, | ||
end: 173, | ||
length: 12 | ||
@@ -221,3 +220,3 @@ } | ||
start: 178, | ||
end: 219, | ||
end: 218, | ||
length: 41 | ||
@@ -231,3 +230,3 @@ }, | ||
line: 13, | ||
character: 4 | ||
character: 3 | ||
}, | ||
@@ -237,3 +236,3 @@ chunks: [ | ||
start: 178, | ||
end: 219, | ||
end: 218, | ||
length: 41 | ||
@@ -251,3 +250,3 @@ } | ||
start: 203, | ||
end: 214, | ||
end: 213, | ||
length: 11 | ||
@@ -261,3 +260,3 @@ }, | ||
line: 12, | ||
character: 15 | ||
character: 14 | ||
}, | ||
@@ -267,3 +266,3 @@ chunks: [ | ||
start: 203, | ||
end: 214, | ||
end: 213, | ||
length: 11 | ||
@@ -270,0 +269,0 @@ } |
var munit = global.munit, | ||
CSSTree = global.CSSTree; | ||
munit( 'AtRule.init', function( assert ) { | ||
var position = new CSSTree.Position( 25 ), | ||
atrule = new CSSTree.AtRule( " @import 'test.css' ", position ); | ||
assert.equal( 'atrule', atrule.atrule, "@import 'test.css'" ); | ||
assert.equal( 'position', atrule.position, position ); | ||
assert.equal( 'rules', atrule.rules, undefined ); | ||
assert.equal( 'branches', atrule.branches, undefined ); | ||
assert.deepEqual( 'parts', atrule.parts, [ "@import", "'test.css'" ] ); | ||
}); | ||
munit( 'AtRule', { | ||
munit( 'AtRule.parts', function( assert ) { | ||
var atrule = new CSSTree.AtRule(); | ||
// Initialization | ||
init: function( assert ) { | ||
var position = new CSSTree.Position( 25 ), | ||
atrule = new CSSTree.AtRule( " @import 'test.css' ", position ); | ||
[ | ||
assert.equal( 'atrule', atrule.atrule, "@import 'test.css'" ); | ||
assert.equal( 'position', atrule.position, position ); | ||
assert.equal( 'rules', atrule.rules, undefined ); | ||
assert.equal( 'branches', atrule.branches, undefined ); | ||
assert.deepEqual( 'parts', atrule.parts, [ "@import", "'test.css'" ] ); | ||
}, | ||
{ | ||
name: 'Basic', | ||
atrule: "@import 'test.css'", | ||
parts: [ | ||
"@import", | ||
"'test.css'" | ||
] | ||
}, | ||
// Testing string breakdown handle | ||
breakdown: function( assert ) { | ||
var atrule = new CSSTree.AtRule(); | ||
{ | ||
name: 'Extendend', | ||
atrule: '@media print and (color), projection and (device-aspect-ratio: 16/9)', | ||
parts: [ | ||
'@media', | ||
'print', | ||
'and', | ||
'(color)', | ||
',', | ||
'projection', | ||
'and', | ||
'(device-aspect-ratio: 16/9)' | ||
] | ||
}, | ||
[ | ||
{ | ||
name: 'URL Import', | ||
atrule: "@import url(\"crazyurl.css?semi=yes;&email=corey@codenothing.com\")", | ||
parts: [ | ||
"@import", | ||
"url(\"crazyurl.css?semi=yes;&email=corey@codenothing.com\")" | ||
] | ||
}, | ||
{ | ||
name: 'Basic', | ||
atrule: "@import 'test.css'", | ||
parts: [ | ||
"@import", | ||
"'test.css'" | ||
] | ||
}, | ||
{ | ||
name: 'Escaped Quotes', | ||
atrule: "@import url('crazyurl.css?semi=yes;&email=core\\'y@codenothing.com')", | ||
parts: [ | ||
"@import", | ||
"url('crazyurl.css?semi=yes;&email=core\\'y@codenothing.com')" | ||
] | ||
} | ||
{ | ||
name: 'Extendend', | ||
atrule: '@media print and (color), projection and (device-aspect-ratio: 16/9)', | ||
parts: [ | ||
'@media', | ||
'print', | ||
'and', | ||
'(color)', | ||
',', | ||
'projection', | ||
'and', | ||
'(device-aspect-ratio: 16/9)' | ||
] | ||
}, | ||
].forEach(function( object ) { | ||
atrule.atrule = object.atrule; | ||
atrule.breakdown(); | ||
assert.deepEqual( object.name, atrule.parts, object.parts ); | ||
}); | ||
{ | ||
name: 'URL Import', | ||
atrule: "@import url(\"crazyurl.css?semi=yes;&email=corey@codenothing.com\")", | ||
parts: [ | ||
"@import", | ||
"url(\"crazyurl.css?semi=yes;&email=corey@codenothing.com\")" | ||
] | ||
}, | ||
{ | ||
name: 'Escaped Quotes', | ||
atrule: "@import url('crazyurl.css?semi=yes;&email=core\\'y@codenothing.com')", | ||
parts: [ | ||
"@import", | ||
"url('crazyurl.css?semi=yes;&email=core\\'y@codenothing.com')" | ||
] | ||
} | ||
].forEach(function( object ) { | ||
atrule.atrule = object.atrule; | ||
atrule.breakdown(); | ||
assert.deepEqual( object.name, atrule.parts, object.parts ); | ||
}); | ||
}, | ||
}); |
@@ -5,23 +5,25 @@ var munit = global.munit, | ||
// Put core functionality at the highest priority | ||
munit( 'CSSTree', { priority: 1.0 } ); | ||
munit( 'CSSTree', { priority: 1.0 }, { | ||
// Add basic existance tests to ensure api stays consistent through versions | ||
// THESE TESTS CANNOT CHANGE | ||
munit( 'CSSTree.init', function( assert ) { | ||
var css = "body { color: red; }", | ||
tree = new CSSTree( css ); | ||
// Add basic existance tests to ensure api stays consistent through versions | ||
// THESE TESTS SHOULD NOT CHANGE | ||
init: function( assert ) { | ||
var css = "body { color: red; }", | ||
tree = new CSSTree( css ); | ||
assert.equal( 'css', tree.css, css ); | ||
assert.equal( 'length', tree.length, css.length ); | ||
assert.isArray( 'branches', tree.branches ); | ||
}); | ||
assert.exists( 'iter', tree.iter ) | ||
.equal( 'css', tree.css, css ) | ||
.isArray( 'branches', tree.branches ); | ||
}, | ||
// Same concept, make sure sub objects stay consistent through versions | ||
// THESE TESTS CANNOT CHANGE | ||
munit( 'CSSTree.static', function( assert ) { | ||
assert.isFunction( 'Position', CSSTree.Position ); | ||
assert.isFunction( 'Selector', CSSTree.Selector ); | ||
assert.isFunction( 'Comment', CSSTree.Comment ); | ||
assert.isFunction( 'AtRule', CSSTree.AtRule ); | ||
assert.isFunction( 'Rule', CSSTree.Rule ); | ||
// Same concept, make sure sub objects stay consistent through versions | ||
// THESE TESTS SHOULD NOT CHANGE | ||
'static': function( assert ) { | ||
assert.isFunction( 'Position', CSSTree.Position ) | ||
.isFunction( 'Selector', CSSTree.Selector ) | ||
.isFunction( 'Comment', CSSTree.Comment ) | ||
.isFunction( 'AtRule', CSSTree.AtRule ) | ||
.isFunction( 'Rule', CSSTree.Rule ); | ||
}, | ||
}); |
@@ -27,50 +27,40 @@ var munit = global.munit, | ||
// Lower sheet rendering priority to allow focused tests to run first | ||
munit( 'Files', { priority: munit.PRIORITY_LOW } ); | ||
munit( 'Files', { priority: munit.PRIORITY_LOW }, { | ||
// Sheet testing | ||
sheets: function( assert ) { | ||
fs.readdirSync( SHEETS ).forEach(function( dir ) { | ||
if ( ! fs.statSync( SHEETS + dir ).isDirectory() ) { | ||
return; | ||
} | ||
// Sheet testing | ||
munit( 'Files.Sheets', function( assert ) { | ||
fs.readdirSync( SHEETS ).forEach(function( dir ) { | ||
if ( ! fs.statSync( SHEETS + dir ).isDirectory() ) { | ||
return; | ||
} | ||
// Sheet setup | ||
var name = 'sheet-' + dir, | ||
branch = name + '-branch-', | ||
sheet = fs.readFileSync( SHEETS + dir + '/sheet.css', 'utf8' ), | ||
branches = RemovePositions( CSSTree( sheet ).branches ), | ||
match = require( SHEETS + dir + '/tree.js' ); | ||
var name = 'sheet-' + dir, | ||
branch = name + '-branch-', | ||
sheet = fs.readFileSync( SHEETS + dir + '/sheet.css', 'utf8' ), | ||
branches = RemovePositions( CSSTree( sheet ).branches ), | ||
match = require( SHEETS + dir + '/tree.js' ); | ||
// Make sure both sheets contain the same # of branches | ||
assert.equal( name, branches.length, match.length ); | ||
// Test each branch individually to help in testing | ||
branches.forEach(function( object, index ) { | ||
assert.deepEqual( branch + index, object, match[ index ] ); | ||
assert.deepEqual( name, branches, match ); | ||
}); | ||
}); | ||
}); | ||
}, | ||
// Position Testing | ||
positions: function( assert ) { | ||
fs.readdirSync( POSITIONS ).forEach(function( dir ) { | ||
if ( ! fs.statSync( POSITIONS + dir ).isDirectory() ) { | ||
return; | ||
} | ||
// Position Testing | ||
munit( 'Files.Positions', function( assert ) { | ||
fs.readdirSync( POSITIONS ).forEach(function( dir ) { | ||
if ( ! fs.statSync( POSITIONS + dir ).isDirectory() ) { | ||
return; | ||
} | ||
// Sheet setup | ||
var name = 'positions-' + dir, | ||
branch = name + '-branch-', | ||
sheet = fs.readFileSync( POSITIONS + dir + '/sheet.css', 'utf8' ), | ||
branches = CSSTree( sheet ).branches, | ||
match = require( POSITIONS + dir + '/tree.js' ); | ||
var name = 'positions-' + dir, | ||
branch = name + '-branch-', | ||
sheet = fs.readFileSync( POSITIONS + dir + '/sheet.css', 'utf8' ), | ||
branches = CSSTree( sheet ).branches, | ||
match = require( POSITIONS + dir + '/tree.js' ); | ||
assert.deepEqual( name, branches, match ); | ||
}); | ||
}, | ||
// Make sure both sheets contain the same # of branches | ||
assert.equal( name, branches.length, match.length ); | ||
// Test each branch individually to help in testing | ||
branches.forEach(function( object, index ) { | ||
assert.deepEqual( branch + index, object, match[ index ] ); | ||
}); | ||
}); | ||
}); |
var munit = global.munit, | ||
CSSTree = global.CSSTree; | ||
munit( 'Rule.init', function( assert ) { | ||
var position = new CSSTree.Position( 25 ), | ||
rule = new CSSTree.Rule( " color ", " red !important ", position ); | ||
munit( 'Rule', { | ||
assert.equal( 'property', rule.property, "color" ); | ||
assert.equal( 'value', rule.value, "red !important" ); | ||
assert.equal( 'position', rule.position, position ); | ||
assert.deepEqual( 'parts', rule.parts, [ "red", "!important" ] ); | ||
}); | ||
// Testing initialization | ||
init: function( assert ) { | ||
var position = new CSSTree.Position( 25 ), | ||
rule = new CSSTree.Rule( " color ", " red !important ", position ); | ||
munit( 'Rule.parts', function( assert ) { | ||
var rule = new CSSTree.Rule(); | ||
assert.equal( 'property', rule.property, "color" ); | ||
assert.equal( 'value', rule.value, "red !important" ); | ||
assert.equal( 'position', rule.position, position ); | ||
assert.deepEqual( 'parts', rule.parts, [ "red", "!important" ] ); | ||
}, | ||
[ | ||
// Testing string breadown of rule values | ||
breakdown: function( assert ) { | ||
var rule = new CSSTree.Rule(); | ||
{ | ||
name: 'Basic', | ||
value: 'red !important', | ||
parts: [ | ||
'red', | ||
'!important' | ||
] | ||
}, | ||
[ | ||
{ | ||
name: 'Slash', | ||
value: '10px / 20px', | ||
parts: [ | ||
'10px', | ||
'/', | ||
'20px' | ||
] | ||
}, | ||
{ | ||
name: 'Basic', | ||
value: 'red !important', | ||
parts: [ | ||
'red', | ||
'!important' | ||
] | ||
}, | ||
{ | ||
name: 'Comma', | ||
value: 'Sans-Seriff,Comic-Sans', | ||
parts: [ | ||
'Sans-Seriff', | ||
',', | ||
'Comic-Sans' | ||
] | ||
}, | ||
{ | ||
name: 'Slash', | ||
value: '10px / 20px', | ||
parts: [ | ||
'10px', | ||
'/', | ||
'20px' | ||
] | ||
}, | ||
{ | ||
name: 'Value Separators', | ||
value: '10px "Red Light" \'Green Light\' url(http://www.google.com) "Testi\\"ng Esc\\"apes"', | ||
parts: [ | ||
'10px', | ||
'"Red Light"', | ||
"'Green Light'", | ||
'url(http://www.google.com)', | ||
'"Testi\\"ng Esc\\"apes"' | ||
] | ||
} | ||
{ | ||
name: 'Comma', | ||
value: 'Sans-Seriff,Comic-Sans', | ||
parts: [ | ||
'Sans-Seriff', | ||
',', | ||
'Comic-Sans' | ||
] | ||
}, | ||
].forEach(function( object ) { | ||
rule.value = object.value; | ||
rule.breakdown(); | ||
assert.deepEqual( object.name, rule.parts, object.parts ); | ||
}); | ||
{ | ||
name: 'Value Separators', | ||
value: '10px "Red Light" \'Green Light\' url(http://www.google.com) "Testi\\"ng Esc\\"apes"', | ||
parts: [ | ||
'10px', | ||
'"Red Light"', | ||
"'Green Light'", | ||
'url(http://www.google.com)', | ||
'"Testi\\"ng Esc\\"apes"' | ||
] | ||
} | ||
].forEach(function( object ) { | ||
rule.value = object.value; | ||
rule.breakdown(); | ||
assert.deepEqual( object.name, rule.parts, object.parts ); | ||
}); | ||
}, | ||
}); |
var munit = global.munit, | ||
CSSTree = global.CSSTree; | ||
munit( 'Selector.init', function( assert ) { | ||
var position = new CSSTree.Position( 25 ), | ||
rules = [ 1, 2, 3 ], | ||
selector = new CSSTree.Selector( " html body ", rules, position ); | ||
munit( 'Selector', { | ||
assert.equal( 'selector', selector.selector, "html body" ); | ||
assert.equal( 'position', selector.position, position ); | ||
assert.equal( 'rules', selector.rules, rules ); | ||
assert.equal( 'branches', selector.branches, undefined ); | ||
assert.deepEqual( 'parts', selector.parts, [ "html", "body" ] ); | ||
}); | ||
// Testing selector init | ||
init: function( assert ) { | ||
var position = new CSSTree.Position( 25 ), | ||
rules = [ 1, 2, 3 ], | ||
selector = new CSSTree.Selector( " html body ", rules, position ); | ||
munit( 'Selector.parts', function( assert ) { | ||
var selector = new CSSTree.Selector(); | ||
assert.equal( 'selector', selector.selector, "html body" ); | ||
assert.equal( 'position', selector.position, position ); | ||
assert.equal( 'rules', selector.rules, rules ); | ||
assert.equal( 'branches', selector.branches, undefined ); | ||
assert.deepEqual( 'parts', selector.parts, [ "html", "body" ] ); | ||
}, | ||
[ | ||
{ | ||
name: 'Basic', | ||
selector: "html body", | ||
parts: [ | ||
'html', | ||
'body' | ||
] | ||
}, | ||
// Testing breakdown of selector string | ||
breakdown: function( assert ) { | ||
var selector = new CSSTree.Selector(); | ||
{ | ||
name: 'Nested', | ||
selector: "html body.class span", | ||
parts: [ | ||
'html', | ||
[ | ||
'body', | ||
'.class' | ||
], | ||
'span' | ||
] | ||
}, | ||
[ | ||
{ | ||
name: 'Basic', | ||
selector: "html body", | ||
parts: [ | ||
'html', | ||
'body' | ||
] | ||
}, | ||
{ | ||
name: 'Brace', | ||
selector: "div a[data-tag='testing']", | ||
parts: [ | ||
'div', | ||
[ | ||
'a', | ||
"[data-tag='testing']" | ||
{ | ||
name: 'Nested', | ||
selector: "html body.class span", | ||
parts: [ | ||
'html', | ||
[ | ||
'body', | ||
'.class' | ||
], | ||
'span' | ||
] | ||
] | ||
}, | ||
}, | ||
{ | ||
name: 'Nested Brace Filter', | ||
selector: "div a.class[data-tag='testing']:first-child", | ||
parts: [ | ||
'div', | ||
[ | ||
'a', | ||
'.class', | ||
"[data-tag='testing']", | ||
':first-child' | ||
{ | ||
name: 'Brace', | ||
selector: "div a[data-tag='testing']", | ||
parts: [ | ||
'div', | ||
[ | ||
'a', | ||
"[data-tag='testing']" | ||
] | ||
] | ||
] | ||
}, | ||
}, | ||
{ | ||
name: 'Separator', | ||
selector: "div > p", | ||
parts: [ | ||
'div', | ||
'>', | ||
'p' | ||
] | ||
}, | ||
{ | ||
name: 'Nested Brace Filter', | ||
selector: "div a.class[data-tag='testing']:first-child", | ||
parts: [ | ||
'div', | ||
[ | ||
'a', | ||
'.class', | ||
"[data-tag='testing']", | ||
':first-child' | ||
] | ||
] | ||
}, | ||
{ | ||
name: 'All Separators', | ||
selector: "div > p ~ a + b, *", | ||
parts: [ | ||
'div', | ||
'>', | ||
'p', | ||
'~', | ||
'a', | ||
'+', | ||
'b', | ||
',', | ||
'*' | ||
] | ||
}, | ||
{ | ||
name: 'Separator', | ||
selector: "div > p", | ||
parts: [ | ||
'div', | ||
'>', | ||
'p' | ||
] | ||
}, | ||
{ | ||
name: 'Brace Separator', | ||
selector: "div p, [data-target=alpha]", | ||
parts: [ | ||
'div', | ||
'p', | ||
',', | ||
'[data-target=alpha]' | ||
] | ||
}, | ||
{ | ||
name: 'All Separators', | ||
selector: "div > p ~ a + b, *", | ||
parts: [ | ||
'div', | ||
'>', | ||
'p', | ||
'~', | ||
'a', | ||
'+', | ||
'b', | ||
',', | ||
'*' | ||
] | ||
}, | ||
{ | ||
name: 'Brace Separator Nested', | ||
selector: "div p:first-child, [data-target=alpha]:last-child", | ||
parts: [ | ||
'div', | ||
[ | ||
{ | ||
name: 'Brace Separator', | ||
selector: "div p, [data-target=alpha]", | ||
parts: [ | ||
'div', | ||
'p', | ||
':first-child' | ||
], | ||
',', | ||
[ | ||
'[data-target=alpha]', | ||
':last-child' | ||
',', | ||
'[data-target=alpha]' | ||
] | ||
] | ||
} | ||
}, | ||
].forEach(function( object ) { | ||
selector.selector = object.selector; | ||
selector.breakdown(); | ||
assert.deepEqual( object.name, selector.parts, object.parts ); | ||
}); | ||
{ | ||
name: 'Brace Separator Nested', | ||
selector: "div p:first-child, [data-target=alpha]:last-child", | ||
parts: [ | ||
'div', | ||
[ | ||
'p', | ||
':first-child' | ||
], | ||
',', | ||
[ | ||
'[data-target=alpha]', | ||
':last-child' | ||
] | ||
] | ||
} | ||
].forEach(function( object ) { | ||
selector.selector = object.selector; | ||
selector.breakdown(); | ||
assert.deepEqual( object.name, selector.parts, object.parts ); | ||
}); | ||
}, | ||
}); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Install scripts
Supply chain riskInstall scripts are run when the package is installed. The majority of malware in npm is hidden in install scripts.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
267883
81
4511
1
7
1
1
+ Addedstring-iterator@0.0.1
+ Addedstring-iterator@0.0.1(transitive)