Socket
Socket
Sign inDemoInstall

csstree

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

csstree - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

.travis.yml

11

.nodelint.json

@@ -5,4 +5,11 @@ {

".git/",
"node_modules/"
]
"node_modules/",
"dist/",
"demo/CSSTree.js"
],
"linters": {
"jshint": {
"node": true
}
}
}

@@ -29,3 +29,16 @@ var fs = require( 'fs' ),

function( dir, callback ) {
fs.writeFile( dir + 'CSSTree.js', contents, 'utf8', callback );
fs.exists( dir, function( exists ) {
if ( exists ) {
fs.writeFile( dir + 'CSSTree.js', contents, 'utf8', callback );
}
else {
fs.mkdir( dir, function( e ) {
if ( e ) {
throw e;
}
fs.writeFile( dir + 'CSSTree.js', contents, 'utf8', callback );
});
}
});
},

@@ -32,0 +45,0 @@ function( e ) {

2

build/headers.txt
/*
* CSSTree 0.0.1
* CSSTree 0.0.2
* Corey Hart @ http://www.codenothing.com
* MIT License http://www.codenothing.com/license
*/

@@ -1,8 +0,13 @@

global.CSSTree = require( '../' );
global.MUnit = require( 'munit' );
var CSSTree = global.CSSTree = require( '../' );
var munit = global.munit = require( 'munit' );
// Defaults
MUnit.Defaults.Settings.stopOnFail = true;
// Only stop test suite when running make test
if ( ! process.env.NODE_TEST_NO_SKIP ) {
munit.defaults.settings.stopOnFail = true;
}
// Run tests
MUnit.render( __dirname + '/../test/' );
munit.render( __dirname + '/../test/', {
junit: __dirname + '/results/',
junitPrefix: process.version.replace( /\./g, '_' )
});

@@ -7,3 +7,9 @@ {

"counter/textarea.js"
]
],
"linters": {
"jshint": {
"node": false,
"browser": true
}
}
}

@@ -1,25 +0,8 @@

jQuery(function( jQuery ) {
var textbox = jQuery( 'textarea' ),
window.jQuery(function( jQuery ) {
var alert = window.alert,
textbox = jQuery( 'textarea' ),
selectStart = jQuery( 'input[name=start]' ),
selectEnd = jQuery( 'input[name=end]' ),
positionInfo = jQuery( '#position' );
// Update caret position on any user action
textbox.on( 'keyup', updatePosition )
.on( 'click', updatePosition )
.on( 'focus', updatePosition );
// Watch for highlight trigger
jQuery( 'form' ).on( 'submit', function( event ) {
select(
parseInt( selectStart.val() || '0', 10 ),
parseInt( selectEnd.val() || '0', 10 )
);
scroll();
return false;
});
// Highlighting input ranges

@@ -78,2 +61,18 @@ function select( start, end ) {

}
// Update caret position on any user action
textbox.on( 'keyup', updatePosition )
.on( 'click', updatePosition )
.on( 'focus', updatePosition );
// Watch for highlight trigger
jQuery( 'form' ).on( 'submit', function( event ) {
select(
parseInt( selectStart.val() || '0', 10 ),
parseInt( selectEnd.val() || '0', 10 )
);
scroll();
return false;
});
});

@@ -1,3 +0,5 @@

jQuery(function( jQuery ) {
var contentArea = jQuery( '.content' ),
window.jQuery(function( jQuery ) {
var CSSTree = window.CSSTree,
alert = window.alert,
contentArea = jQuery( '.content' ),
textarea = jQuery( 'textarea' ),

@@ -4,0 +6,0 @@ button = jQuery( 'button' ),

@@ -13,3 +13,3 @@ var fs = require( 'fs' ),

// Attach exporter for parent modules
CSSTree.exportScript = function( callback ) {
global.CSSTree.exportScript = function( callback ) {
if ( callback ) {

@@ -16,0 +16,0 @@ fs.readFile( __dirname + '/dist/CSSTree.js', 'utf8', callback );

@@ -23,3 +23,4 @@ var ratruleseek = /"|'|\(/,

parts = [], part = '',
i = -1, l = atrule.length, c = '';
i = -1, l = atrule.length, c = '',
seek;

@@ -79,2 +80,2 @@ for ( ; ++i < l; ) {

CSSTree.AtRule = AtRule;
global.CSSTree.AtRule = AtRule;

@@ -13,2 +13,2 @@ function Comment( comment, nested, position ) {

CSSTree.Comment = Comment;
global.CSSTree.Comment = Comment;
var rnewlineseek = /(\r\n|\r|\n)/g,
rwhitespace = /(\s|\t|\r\n|\r|\n)/;
rwhitespace = /(\s|\t|\r\n|\r|\n)/,
leftTrim = /^(\r\n|\r|\n|\t|\s)*/;

@@ -87,2 +88,3 @@

selector = '',
character,
parts = [], nested = null, part = '',

@@ -109,4 +111,4 @@ peek, branch;

else if ( self.c == '{' && selector.trim()[ 0 ] == '@' ) {
branch = self.nested( selector.trim(), position );
branch.position = position.markEnd( self.i );
branch = self.nested( selector, position );
branch.position = position.markEnd( self.i + 1 );
return self.branches.push( branch );

@@ -140,3 +142,3 @@ }

// Catch end of file queries without semi-colon
if ( ( selector = selector.trim() ).length ) {
if ( selector.trim().length ) {
return self.branches.push(

@@ -289,3 +291,3 @@ new CSSTree.AtRule( selector, position.markEnd( self.i ) )

string = '',
peek, index, rule, subPosition,
peek, index, rule, subPosition, character,
block = atrule.trim()[ 0 ] == '@' ?

@@ -299,6 +301,2 @@ new CSSTree.AtRule( atrule, position ) :

// Escaped string
if ( self.c == '\\' ) {
string += self.c + self.css[ ++self.i ];
}
// Comment

@@ -312,3 +310,3 @@ if ( self.c == '/' && peek == '*' ) {

else if ( self.c == ';' ) {
subPosition = new CSSTree.Position( self.i - string.length );
subPosition = new CSSTree.Position( self.i - string.trim().length );
subPosition.markEnd( self.i );

@@ -342,4 +340,8 @@

// Nested branches should start tracking at the first character, not whitespace
string = string.replace( leftTrim, '' );
// Travel down the tree
subPosition = new CSSTree.Position( self.i - string.length, position );
block.branches.push( self.nested( string.trim(), subPosition ) );
block.branches.push( self.nested( string, subPosition ) );
string = '';

@@ -378,2 +380,3 @@ }

block.position.markEnd( self.i + 1, false );
return block;

@@ -425,7 +428,7 @@ }

_charPosition: function( pos ) {
var self = this, line = self._newlines.length, chracter = 0;
var self = this, line = self._newlines.length, character = 0;
while ( line-- ) {
if ( pos > self._newlines[ line ] ) {
chracter = self._newlines[ line ] + 1;
character = self._newlines[ line ] + 1;
break;

@@ -437,3 +440,3 @@ }

line: line + 2,
character: ( pos + 1 ) - chracter
character: ( pos + 1 ) - character
};

@@ -440,0 +443,0 @@ }

@@ -68,2 +68,2 @@ function Position( start, _parent ) {

CSSTree.Position = Position;
global.CSSTree.Position = Position;

@@ -84,2 +84,2 @@ var rwhitespace = /(\s|\t|\r\n|\r|\n)/,

CSSTree.Rule = Rule;
global.CSSTree.Rule = Rule;

@@ -124,2 +124,2 @@ var rselectornested = /[:#\[\.]/,

CSSTree.Selector = Selector;
global.CSSTree.Selector = Selector;

@@ -8,3 +8,3 @@ {

"homepage": "http://codenothing.github.com/CSSTree/",
"version": "0.0.1",
"version": "0.0.2",
"main": "./index.js",

@@ -14,9 +14,12 @@ "engines": {

},
"scripts": {
"test": "make test"
},
"dependencies": {
},
"devDependencies": {
"nlint": "0.0.3",
"munit": "0.0.2",
"async": "0.2.6"
"nlint": "0.0.4",
"munit": "0.0.5",
"async": "0.2.9"
}
}

@@ -5,2 +5,3 @@ # CSSTree

[![Build Status](https://travis-ci.org/codenothing/CSSTree.png?branch=master)](https://travis-ci.org/codenothing/CSSTree)

@@ -7,0 +8,0 @@ ### Installation

@@ -1,2 +0,5 @@

MUnit( 'AtRule.init', function( assert ) {
var munit = global.munit,
CSSTree = global.CSSTree;
munit( 'AtRule.init', function( assert ) {
var position = new CSSTree.Position( 25 ),

@@ -12,3 +15,3 @@ atrule = new CSSTree.AtRule( " @import 'test.css' ", position );

MUnit( 'AtRule.parts', function( assert ) {
munit( 'AtRule.parts', function( assert ) {
var atrule = new CSSTree.AtRule();

@@ -15,0 +18,0 @@

@@ -1,2 +0,5 @@

MUnit( 'Comment.init', function( assert ) {
var munit = global.munit,
CSSTree = global.CSSTree;
munit( 'Comment.init', function( assert ) {
var position = new CSSTree.Position( 25 ),

@@ -3,0 +6,0 @@ comment = new CSSTree.Comment( " /* Test Comment */ ", null, position );

@@ -1,6 +0,10 @@

MUnit( 'CSSTree', { priority: 1.0 } );
var munit = global.munit,
CSSTree = global.CSSTree;
// Put core functionality at the highest priority
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 ) {
munit( 'CSSTree.init', function( assert ) {
var css = "body { color: red; }",

@@ -16,3 +20,3 @@ tree = new CSSTree( css );

// THESE TESTS CANNOT CHANGE
MUnit( 'CSSTree.static', function( assert ) {
munit( 'CSSTree.static', function( assert ) {
assert.isFunction( 'Position', CSSTree.Position );

@@ -19,0 +23,0 @@ assert.isFunction( 'Selector', CSSTree.Selector );

@@ -1,2 +0,4 @@

var fs = require( 'fs' ),
var munit = global.munit,
CSSTree = global.CSSTree,
fs = require( 'fs' ),
SHEETS = __dirname + '/sheets/',

@@ -25,7 +27,7 @@ POSITIONS = __dirname + '/positions/';

// 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
MUnit( 'Files.Sheets', function( assert ) {
munit( 'Files.Sheets', function( assert ) {
fs.readdirSync( SHEETS ).forEach(function( dir ) {

@@ -36,6 +38,15 @@ if ( ! fs.statSync( SHEETS + dir ).isDirectory() ) {

var sheet = fs.readFileSync( SHEETS + dir + '/sheet.css', 'utf8' ),
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' );
assert.deepEqual( 'sheet-' + dir, RemovePositions( CSSTree( sheet ).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 ] );
});
});

@@ -46,3 +57,3 @@ });

// Position Testing
MUnit( 'Files.Positions', function( assert ) {
munit( 'Files.Positions', function( assert ) {
fs.readdirSync( POSITIONS ).forEach(function( dir ) {

@@ -53,7 +64,16 @@ if ( ! fs.statSync( POSITIONS + dir ).isDirectory() ) {

var sheet = fs.readFileSync( POSITIONS + dir + '/sheet.css', 'utf8' ),
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( 'positions-' + dir, CSSTree( sheet ).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 ] );
});
});
});

@@ -1,2 +0,5 @@

MUnit( 'Position.init', function( assert ) {
var munit = global.munit,
CSSTree = global.CSSTree;
munit( 'Position.init', function( assert ) {
var position = new CSSTree.Position( 25 );

@@ -3,0 +6,0 @@

@@ -1,2 +0,5 @@

MUnit( 'Rule.init', function( assert ) {
var munit = global.munit,
CSSTree = global.CSSTree;
munit( 'Rule.init', function( assert ) {
var position = new CSSTree.Position( 25 ),

@@ -11,3 +14,3 @@ rule = new CSSTree.Rule( " color ", " red !important ", position );

MUnit( 'Rule.parts', function( assert ) {
munit( 'Rule.parts', function( assert ) {
var rule = new CSSTree.Rule();

@@ -14,0 +17,0 @@

@@ -1,2 +0,5 @@

MUnit( 'Selector.init', function( assert ) {
var munit = global.munit,
CSSTree = global.CSSTree;
munit( 'Selector.init', function( assert ) {
var position = new CSSTree.Position( 25 ),

@@ -13,3 +16,3 @@ rules = [ 1, 2, 3 ],

MUnit( 'Selector.parts', function( assert ) {
munit( 'Selector.parts', function( assert ) {
var selector = new CSSTree.Selector();

@@ -16,0 +19,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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