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

homunculus

Package Overview
Dependencies
Maintainers
2
Versions
164
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

homunculus - npm Package Compare versions

Comparing version 0.2.8 to 0.2.9-1

2

package.json
{
"name": "homunculus",
"version": "0.2.8",
"version": "0.2.9-1",
"description": "A lexer&parser by Javascript",

@@ -5,0 +5,0 @@ "maintainers": [

var Lexer = require('./Lexer');
var Token = require('./Token');
var character = require('../util/character');
var S = {
'\n': true,
'\r': true,
' ': true,
'\t': true
};
var CssLexer = Lexer.extend(function(rule) {

@@ -14,3 +20,3 @@ Lexer.call(this, rule);

this.isKw = false;
this.isSelector = false;
this.isSelector = true;
this.depth = 0;

@@ -30,11 +36,8 @@ }).methods({

if(this.parenthese && this.isUrl) {
if(!{
"'": true,
'"': true,
' ': true,
'\n': true,
'\r': true,
'\t': true,
')': true
}.hasOwnProperty(this.peek)) {
if(!S.hasOwnProperty(this.peek)
&& !{
"'": true,
'"': true,
')': true
}.hasOwnProperty(this.peek)) {
this.dealPt(temp);

@@ -51,2 +54,7 @@ this.isUrl = false;

//回调可自定义处理匹配的token
if(match.callback) {
match.callback(token);
}
var s = token.content();

@@ -79,15 +87,18 @@ switch(token.type()) {

case Token.ID:
this.isKw = false;
this.isSelector = false;
if(this.bracket) {
token.type(Token.ATTR);
this.isUrl = false;
}
else if(this.isValue) {
token.type(Token.PROPERTY);
if(this.rule.colors().hasOwnProperty(s)) {
token.type(Token.NUMBER);
this.isUrl = false;
}
else {
else if(this.rule.keyWords().hasOwnProperty(s)
|| this.rule.values().hasOwnProperty(s)) {
token.type(Token.PROPERTY);
this.isUrl = s == 'url' || s == 'format';
}
this.isKw = false;
}

@@ -99,2 +110,3 @@ else {

this.isKw = true;
this.isUrl = false;
}

@@ -108,2 +120,4 @@ else {

this.isSelector = true;
this.isUrl = false;
this.isKw = false;
}

@@ -114,3 +128,3 @@ }

case Token.PSEUDO:
if(!this.isSelector) {
if(this.isKw || this.isValue) {
continue;

@@ -124,8 +138,2 @@ }

break;
case Token.HACK:
if(!this.depth || !this.isValue) {
token.type(Token.IGNORE);
}
this.isUrl = false;
break;
case Token.IMPORTANT:

@@ -138,3 +146,2 @@ if(!this.depth || !this.isValue) {

case Token.SIGN:
this.isNumber = false;
switch(s) {

@@ -146,3 +153,2 @@ case ':':

this.isUrl = false;
this.isKw = false;
this.isSelector = false;

@@ -155,2 +161,3 @@ break;

this.parenthese = true;
this.isSelector = false;
break;

@@ -163,2 +170,3 @@ case ')':

this.parenthese = false;
this.isSelector = false;
case '[':

@@ -169,2 +177,3 @@ if(this.isSelector) {

this.isUrl = false;
this.isSelector = false;
break;

@@ -174,2 +183,3 @@ case ']':

this.isUrl = false;
this.isSelector = false;
break;

@@ -180,2 +190,3 @@ case ';':

this.isUrl = false;
this.isSelector = false;
break;

@@ -188,2 +199,3 @@ case '{':

this.isUrl = false;
this.isSelector = false;
break;

@@ -195,6 +207,31 @@ case '}':

this.isUrl = false;
this.isSelector = false;
this.depth--;
break;
case '*':
if(this.depth) {
if(!this.isValue) {
//LL2确定是selector还是hack
for (var j = this.index; j < length; j++) {
var c = this.code.charAt(j);
if (!S.hasOwnProperty(c)) {
if (c == ':' || c == '{') {
token.type(Token.SELECTOR);
this.isSelector = true;
}
else {
token.type(Token.HACK);
this.isSelector = false;
}
break;
}
}
}
}
else {
token.type(Token.SELECTOR);
this.isSelector = true;
}
break;
case '-':
case '*':
case '_':

@@ -205,7 +242,11 @@ if(this.depth && !this.isValue) {

this.isUrl = false;
this.isSelector = false;
break;
default:
this.isUrl = false;
this.isSelector = false;
break;
}
this.isNumber = false;
this.isKw = false;
break;

@@ -219,10 +260,12 @@ case Token.NUMBER:

}
this.isUrl = false;
break;
case Token.VARS:
this.isKw = true;
this.isSelector = false;
this.isUrl = false;
this.isNumber = false;
break;
}
//回调可自定义处理匹配的token
if(match.callback) {
match.callback(token);
}
temp.push(token);

@@ -250,5 +293,11 @@ this.tokenList.push(token);

if(j == -1) {
j = this.code.indexOf('}', this.index);
if(j == -1) {
j = this.code.length;
j = this.code.length;
if(this.depth) {
j = this.code.indexOf('}', this.index);
if (j == -1) {
j = this.code.length;
}
else {
j--;
}
}

@@ -255,0 +304,0 @@ }

@@ -43,2 +43,3 @@ var Rule = require('./Rule');

self.addMatch(new CompleteEqual(Token.HACK, '\\9'));
self.addMatch(new CompleteEqual(Token.HACK, '\\,'));
self.addMatch(new CompleteEqual(Token.HACK, '-moz-'), null, true);

@@ -52,2 +53,3 @@ self.addMatch(new CompleteEqual(Token.HACK, '-webkit-'), null, true);

self.addMatch(new RegMatch(Token.SELECTOR, /^#\w[\w\-]*/i));
self.addMatch(new RegMatch(Token.VARS, /^var-\w+/i));
self.addMatch(new RegMatch(Token.ID, /^[a-z]\w*(?:-\w+)*/i));

@@ -72,3 +74,4 @@ self.addMatch(new RegMatch(Token.STRING, /^(\\[a-z\d]{4})+/i));

'@keyframes': true,
'@namespace': true
'@namespace': true,
'@-moz-document': true
}.hasOwnProperty(s)) {

@@ -92,5 +95,5 @@ token.type(Token.VARS);

KEYWORDS: 'appearance ascent aspect-ratio azimuth backface-visibility background-attachment background-clip background-color background-image background-origin background-position background-repeat background-size background baseline bbox border-collapse border-color border-image border-radius border-spacing border-style border-top border-right border-bottom border-left border-top-color border-right-color border-bottom-color border-left-color border-top-style border-right-style border-bottom-style border-left-style border-top-width border-right-width border-bottom-width border-left-width border-width border-top-left-radius border-bottom-left-radius border-top-right-radius border-bottom-right-radius border bottom box-shadow box-sizing cap-height caption-side centerline clear clip color color-index content counter-increment counter-reset cue-after cue-before cue cursor definition-src descent device-aspect-ratio device-height device-width direction display elevation empty-cells filter float font-size-adjust font-smoothing font-family font-size font-stretch font-style font-variant font-weight font grid height interpolation-mode left letter-spacing line-height list-style-image list-style-position list-style-type list-style margin-top margin-right margin-bottom margin-left margin marker-offset marks mathline max-aspect-ratio max-device-pixel-ratio max-device-width max-height max-width min-aspect-ratio min-device-pixel-ratio min-device-width min-height min-width monochrome nav-down nav-left nav-right nav-up opacity orphans outline-color outline-style outline-width orientation outline overflow-x overflow-y overflow padding-top padding-right padding-bottom padding-left padding page page-break-after page-break-before page-break-inside pause pause-after pause-before pitch pitch-range play-during position quotes resize resolution right richness scan size slope src speak-header speak-numeral speak-punctuation speak speech-rate stemh stemv stress table-layout text-align top text-decoration text-indent text-justify text-overflow text-shadow text-transform transform transform-origin transition transition-property unicode-bidi unicode-range units-per-em vertical-align visibility voice-family volume white-space widows width widths word-break word-spacing word-wrap x-height z-index zoom'.split(' '),
VALUES: 'above absolute all alpha always antialiased aqua armenian attr aural auto avoid background baseline behind below bicubic bidi-override black blink block blue bold bolder border-box both bottom break-all break-word braille capitalize caption center center-left center-right circle close-quote code collapse color compact condensed content-box continuous counter counters crop cross crosshair cursive dashed decimal decimal-leading-zero default digits disc dotted double ease ease-in ease-out ease-in-out embed embossed e-resize expanded extra-condensed extra-expanded fantasy far-left far-right fast faster fixed flipouttoleft flipouttoright flipouttotop flipouttobottom format fuchsia gray grayscale green groove handheld hebrew help hidden hide high higher icon inline-table inline inset inside inter-ideograph invert italic justify landscape large larger left-side leftwards level lighter lime linear-gradient linear line-through list-item local loud lower-alpha lowercase lower-greek lower-latin lower-roman lower low ltr marker maroon medium message-box middle mix move narrower navy ne-resize no-close-quote none no-open-quote no-repeat normal nowrap n-resize nw-resize oblique olive once opacity open-quote outset outside overline padding-box pointer portrait pre print projection purple red relative repeat repeat-x repeat-y rgb ridge right right-side rightwards rotate rotateX rotateY rtl run-in scale screen scroll semi-condensed semi-expanded separate se-resize show silent silver slower slow small small-caps small-caption smaller soft solid speech spell-out square s-resize static status-bar sub super sw-resize table-caption table-cell table-column table-column-group table-footer-group table-header-group table-row table-row-group teal text-bottom text-top text thick thin top transparent translate tty tv ultra-condensed ultra-expanded underline upper-alpha uppercase upper-latin upper-roman url visible wait white wider width w-resize x-fast x-high x-large x-loud x-low x-slow x-small x-soft xx-large xx-small yellow'.split(' '),
VALUES: 'above absolute all alpha always antialiased aqua armenian attr aural auto avoid background baseline behind below bicubic bidi-override black blink block blue bold bolder border-box both bottom break-all break-word braille cal capitalize caption center center-left center-right circle close-quote code collapse color compact condensed content-box continuous counter counters crop cross crosshair cursive dashed decimal decimal-leading-zero default digits disc dotted double ease ease-in ease-out ease-in-out embed embossed e-resize expanded extra-condensed extra-expanded fantasy far-left far-right fast faster fixed flipouttoleft flipouttoright flipouttotop flipouttobottom format fuchsia gray grayscale green groove handheld hebrew help hidden hide high higher icon inline-table inline inset inside inter-ideograph invert italic justify landscape large larger left-side leftwards level lighter lime linear-gradient linear line-through list-item local loud lower-alpha lowercase lower-greek lower-latin lower-roman lower low ltr marker maroon medium message-box middle mix move narrower navy ne-resize no-close-quote none no-open-quote no-repeat normal nowrap n-resize nw-resize oblique olive once opacity open-quote outset outside overline padding-box pointer portrait pre print projection purple red relative repeat repeat-x repeat-y rgb ridge right right-side rightwards rotate rotateX rotateY rtl run-in scale screen scroll semi-condensed semi-expanded separate se-resize show silent silver slower slow small small-caps small-caption smaller soft solid speech spell-out square s-resize static status-bar sub super sw-resize table-caption table-cell table-column table-column-group table-footer-group table-header-group table-row table-row-group teal text-bottom text-top text thick thin top transparent translate tty tv ultra-condensed ultra-expanded underline upper-alpha uppercase upper-latin upper-roman url var visible wait white wider width w-resize x-fast x-high x-large x-loud x-low x-slow x-small x-soft xx-large xx-small yellow'.split(' '),
COLORS: 'black silver gray white maroon red purple fuchsia green lime olive yellow navy blue teal aqua'.split(' ')
});
module.exports = CssRule;
var homunculus = require('../');
var expect = require('expect.js');
var fs = require('fs');
var path = require('path');

@@ -44,3 +43,3 @@

expect(join(tokens)).to.eql(['@media', ' ', 'screen', ' ', 'and', '(', 'width', ':', '800', 'px', ')']);
expect(type(tokens)).to.eql([12, 1, 15, 1, 15, 8, 10, 8, 4, 20, 8]);
expect(type(tokens)).to.eql([12, 1, 15, 1, 5, 8, 10, 8, 4, 20, 8]);
});

@@ -51,3 +50,3 @@ it('multi', function () {

expect(join(tokens)).to.eql(['@media', ' ', 'screen', ',', 'print', ' ', 'and', '(', 'width', ':', '0', ')']);
expect(type(tokens)).to.eql([12, 1, 15, 8, 15, 1, 15, 8, 10, 8, 4, 8]);
expect(type(tokens)).to.eql([12, 1, 15, 8, 15, 1, 5, 8, 10, 8, 4, 8]);
});

@@ -118,2 +117,8 @@ });

});
it('#fff is not number', function () {
var lexer = homunculus.getLexer('css');
var tokens = lexer.parse('#fff{}');
expect(join(tokens)).to.eql(['#fff', '{', '}']);
expect(type(tokens)).to.eql([21, 8, 8]);
});
it('.class', function() {

@@ -131,2 +136,8 @@ var lexer = homunculus.getLexer('css');

});
it('*', function() {
var lexer = homunculus.getLexer('css');
var tokens = lexer.parse('*{}');
expect(join(tokens)).to.eql(['*', '{', '}']);
expect(type(tokens)).to.eql([21, 8, 8]);
});
it('tagname', function () {

@@ -150,4 +161,28 @@ var lexer = homunculus.getLexer('css');

});
it('attr', function() {
it('pseudo at start', function() {
var lexer = homunculus.getLexer('css');
var tokens = lexer.parse(':hover{}');
expect(join(tokens)).to.eql([':hover', '{', '}']);
expect(type(tokens)).to.eql([19, 8, 8]);
});
it('pseudo after ,', function() {
var lexer = homunculus.getLexer('css');
var tokens = lexer.parse('p,:root{}');
expect(join(tokens)).to.eql(['p', ',', ':root', '{', '}']);
expect(type(tokens)).to.eql([21, 8, 19, 8, 8]);
});
it('* and pseudo', function() {
var lexer = homunculus.getLexer('css');
var tokens = lexer.parse('*:first-child+html');
expect(join(tokens)).to.eql(['*', ':first-child', '+', 'html']);
expect(type(tokens)).to.eql([21, 19, 8, 21]);
});
it('pseudo with ()', function() {
var lexer = homunculus.getLexer('css');
var tokens = lexer.parse('body:not(:-moz-handler-blocked)');
expect(join(tokens)).to.eql(['body', ':not(:-moz-handler-blocked)']);
expect(type(tokens)).to.eql([21, 19]);
});
it('attr 1', function() {
var lexer = homunculus.getLexer('css');
var tokens = lexer.parse('a[class*="c"]{}');

@@ -157,2 +192,8 @@ expect(join(tokens)).to.eql(['a', '[', 'class', '*=', '"c"', ']', '{', '}']);

});
it('attr 1', function() {
var lexer = homunculus.getLexer('css');
var tokens = lexer.parse('html[lang]');
expect(join(tokens)).to.eql(['html', '[', 'lang', ']']);
expect(type(tokens)).to.eql([21, 8, 22, 8]);
});
});

@@ -196,2 +237,8 @@ describe('style', function() {

});
it('repeat kw', function() {
var lexer = homunculus.getLexer('css');
var tokens = lexer.parse('p{margin margin:0;}');
expect(join(tokens)).to.eql(['p', '{', 'margin', ' ', 'margin', ':', '0', ';', '}']);
expect(type(tokens)).to.eql([21, 8, 10, 1, 10, 8, 4, 8, 8]);
});
});

@@ -211,17 +258,117 @@ describe('hack', function() {

});
it('out of {} is useless', function() {
it('out of {} is usefull', function() {
var lexer = homunculus.getLexer('css');
var tokens = lexer.parse('*-_\\9');
expect(join(tokens)).to.eql(['*', '-', '_', '\\9']);
expect(type(tokens)).to.eql([8, 8, 8, -2]);
var tokens = lexer.parse('-_\\9');
expect(join(tokens)).to.eql(['-', '_', '\\9']);
expect(type(tokens)).to.eql([8, 8, 17]);
});
it('* out of {} is selector', function() {
var lexer = homunculus.getLexer('css');
var tokens = lexer.parse('*{}');
expect(join(tokens)).to.eql(['*', '{', '}']);
expect(type(tokens)).to.eql([21, 8, 8]);
});
it('@media \\0screen{}', function() {
var lexer = homunculus.getLexer('css');
var tokens = lexer.parse('@media \\0screen{}');
expect(join(tokens)).to.eql(['@media', ' ', '\\0', 'screen', '{', '}']);
expect(type(tokens)).to.eql([12, 1, 17, 15, 8, 8]);
});
it('-moz-', function() {
var lexer = homunculus.getLexer('css');
var tokens = lexer.parse('p{-moz-width:1}');
expect(join(tokens)).to.eql(['p', '{', '-moz-', 'width', ':', '1', '}']);
expect(type(tokens)).to.eql([21, 8, 17, 10, 8, 4, 8]);
});
it('-webkit-', function() {
var lexer = homunculus.getLexer('css');
var tokens = lexer.parse('p{-webkit-width:1}');
expect(join(tokens)).to.eql(['p', '{', '-webkit-', 'width', ':', '1', '}']);
expect(type(tokens)).to.eql([21, 8, 17, 10, 8, 4, 8]);
});
it('-ms-', function() {
var lexer = homunculus.getLexer('css');
var tokens = lexer.parse('p{-ms-width:1}');
expect(join(tokens)).to.eql(['p', '{', '-ms-', 'width', ':', '1', '}']);
expect(type(tokens)).to.eql([21, 8, 17, 10, 8, 4, 8]);
});
it('-o-', function() {
var lexer = homunculus.getLexer('css');
var tokens = lexer.parse('p{-o-width:1}');
expect(join(tokens)).to.eql(['p', '{', '-o-', 'width', ':', '1', '}']);
expect(type(tokens)).to.eql([21, 8, 17, 10, 8, 4, 8]);
});
});
describe('unknow', function() {
it('`', function() {
it('with {}', function() {
var lexer = homunculus.getLexer('css');
var tokens = lexer.parse('`p{}');
expect(join(tokens)).to.eql([ '`p{}' ]);
expect(join(tokens)).to.eql(['`p{}']);
expect(type(tokens)).to.eql([-2]);
});
it('with ;', function() {
var lexer = homunculus.getLexer('css');
var tokens = lexer.parse('`;p{}');
expect(join(tokens)).to.eql(['`;', 'p', '{', '}']);
expect(type(tokens)).to.eql([-2, 21, 8, 8]);
});
it('none', function() {
var lexer = homunculus.getLexer('css');
var tokens = lexer.parse('`p');
expect(join(tokens)).to.eql(['`p']);
expect(type(tokens)).to.eql([-2]);
});
it('in {}', function() {
var lexer = homunculus.getLexer('css');
var tokens = lexer.parse('p{|margin:0}');
expect(join(tokens)).to.eql(['p', '{', '|margin:0', '}']);
expect(type(tokens)).to.eql([21, 8, -2, 8]);
});
it('in {} with out }', function() {
var lexer = homunculus.getLexer('css');
var tokens = lexer.parse('p{|margin:0');
expect(join(tokens)).to.eql(['p', '{', '|margin:0']);
expect(type(tokens)).to.eql([21, 8, -2]);
});
it('in {} with ;', function() {
var lexer = homunculus.getLexer('css');
var tokens = lexer.parse('p{|;margin:0}');
expect(join(tokens)).to.eql(['p', '{', '|;', 'margin', ':', '0', '}']);
expect(type(tokens)).to.eql([21, 8, -2, 10, 8, 4, 8]);
});
});
describe('nesting {}', function() {
it('selector', function() {
var lexer = homunculus.getLexer('css');
var tokens = lexer.parse('p{p{*margin:0;*{}}}');
expect(join(tokens)).to.eql(['p', '{', 'p', '{', '*', 'margin', ':', '0', ';', '*', '{', '}', '}', '}']);
expect(type(tokens)).to.eql([21, 8, 21, 8, 17, 10, 8, 4, 8, 21, 8, 8, 8, 8]);
});
it('#fff is not number', function () {
var lexer = homunculus.getLexer('css');
var tokens = lexer.parse('#fff{#fff{}}');
expect(join(tokens)).to.eql(['#fff', '{', '#fff', '{', '}', '}']);
expect(type(tokens)).to.eql([21, 8, 21, 8, 8, 8]);
});
});
describe('var', function() {
it('normal', function() {
var lexer = homunculus.getLexer('css');
var tokens = lexer.parse('$a:1');
expect(join(tokens)).to.eql([ '$a', ':', '1' ]);
expect(type(tokens)).to.eql([ 16, 8, 4 ]);
});
it('@', function() {
var lexer = homunculus.getLexer('css');
var tokens = lexer.parse('@a:1');
expect(join(tokens)).to.eql([ '@a', ':', '1' ]);
expect(type(tokens)).to.eql([ 16, 8, 4 ]);
});
it('css3', function() {
var lexer = homunculus.getLexer('css');
var tokens = lexer.parse('var-a:1');
expect(join(tokens)).to.eql([ 'var-a', ':', '1' ]);
expect(type(tokens)).to.eql([ 16, 8, 4 ]);
});
});
});

@@ -247,2 +394,12 @@ describe('index test', function() {

});
describe('cache line', function() {
it('normal', function() {
var lexer = homunculus.getLexer('css');
lexer.cache(1);
lexer.parse('body{}\np{}');
expect(lexer.finish()).to.eql(false);
lexer.parseOn();
expect(lexer.finish()).to.eql(true);
});
});
});

@@ -5,2 +5,8 @@ define(function(require, exports, module) {

var character = require('../util/character');
var S = {
'\n': true,
'\r': true,
' ': true,
'\t': true
};
var CssLexer = Lexer.extend(function(rule) {

@@ -16,3 +22,3 @@ Lexer.call(this, rule);

this.isKw = false;
this.isSelector = false;
this.isSelector = true;
this.depth = 0;

@@ -32,11 +38,8 @@ }).methods({

if(this.parenthese && this.isUrl) {
if(!{
"'": true,
'"': true,
' ': true,
'\n': true,
'\r': true,
'\t': true,
')': true
}.hasOwnProperty(this.peek)) {
if(!S.hasOwnProperty(this.peek)
&& !{
"'": true,
'"': true,
')': true
}.hasOwnProperty(this.peek)) {
this.dealPt(temp);

@@ -53,2 +56,7 @@ this.isUrl = false;

//回调可自定义处理匹配的token
if(match.callback) {
match.callback(token);
}
var s = token.content();

@@ -81,15 +89,18 @@ switch(token.type()) {

case Token.ID:
this.isKw = false;
this.isSelector = false;
if(this.bracket) {
token.type(Token.ATTR);
this.isUrl = false;
}
else if(this.isValue) {
token.type(Token.PROPERTY);
if(this.rule.colors().hasOwnProperty(s)) {
token.type(Token.NUMBER);
this.isUrl = false;
}
else {
else if(this.rule.keyWords().hasOwnProperty(s)
|| this.rule.values().hasOwnProperty(s)) {
token.type(Token.PROPERTY);
this.isUrl = s == 'url' || s == 'format';
}
this.isKw = false;
}

@@ -101,2 +112,3 @@ else {

this.isKw = true;
this.isUrl = false;
}

@@ -110,2 +122,4 @@ else {

this.isSelector = true;
this.isUrl = false;
this.isKw = false;
}

@@ -116,3 +130,3 @@ }

case Token.PSEUDO:
if(!this.isSelector) {
if(this.isKw || this.isValue) {
continue;

@@ -126,8 +140,2 @@ }

break;
case Token.HACK:
if(!this.depth || !this.isValue) {
token.type(Token.IGNORE);
}
this.isUrl = false;
break;
case Token.IMPORTANT:

@@ -140,3 +148,2 @@ if(!this.depth || !this.isValue) {

case Token.SIGN:
this.isNumber = false;
switch(s) {

@@ -148,3 +155,2 @@ case ':':

this.isUrl = false;
this.isKw = false;
this.isSelector = false;

@@ -157,2 +163,3 @@ break;

this.parenthese = true;
this.isSelector = false;
break;

@@ -165,2 +172,3 @@ case ')':

this.parenthese = false;
this.isSelector = false;
case '[':

@@ -171,2 +179,3 @@ if(this.isSelector) {

this.isUrl = false;
this.isSelector = false;
break;

@@ -176,2 +185,3 @@ case ']':

this.isUrl = false;
this.isSelector = false;
break;

@@ -182,2 +192,3 @@ case ';':

this.isUrl = false;
this.isSelector = false;
break;

@@ -190,2 +201,3 @@ case '{':

this.isUrl = false;
this.isSelector = false;
break;

@@ -197,6 +209,31 @@ case '}':

this.isUrl = false;
this.isSelector = false;
this.depth--;
break;
case '*':
if(this.depth) {
if(!this.isValue) {
//LL2确定是selector还是hack
for (var j = this.index; j < length; j++) {
var c = this.code.charAt(j);
if (!S.hasOwnProperty(c)) {
if (c == ':' || c == '{') {
token.type(Token.SELECTOR);
this.isSelector = true;
}
else {
token.type(Token.HACK);
this.isSelector = false;
}
break;
}
}
}
}
else {
token.type(Token.SELECTOR);
this.isSelector = true;
}
break;
case '-':
case '*':
case '_':

@@ -207,7 +244,11 @@ if(this.depth && !this.isValue) {

this.isUrl = false;
this.isSelector = false;
break;
default:
this.isUrl = false;
this.isSelector = false;
break;
}
this.isNumber = false;
this.isKw = false;
break;

@@ -221,10 +262,12 @@ case Token.NUMBER:

}
this.isUrl = false;
break;
case Token.VARS:
this.isKw = true;
this.isSelector = false;
this.isUrl = false;
this.isNumber = false;
break;
}
//回调可自定义处理匹配的token
if(match.callback) {
match.callback(token);
}
temp.push(token);

@@ -252,5 +295,11 @@ this.tokenList.push(token);

if(j == -1) {
j = this.code.indexOf('}', this.index);
if(j == -1) {
j = this.code.length;
j = this.code.length;
if(this.depth) {
j = this.code.indexOf('}', this.index);
if (j == -1) {
j = this.code.length;
}
else {
j--;
}
}

@@ -257,0 +306,0 @@ }

@@ -44,2 +44,3 @@ define(function(require, exports, module) {

self.addMatch(new CompleteEqual(Token.HACK, '\\9'));
self.addMatch(new CompleteEqual(Token.HACK, '\\,'));
self.addMatch(new CompleteEqual(Token.HACK, '-moz-'), null, true);

@@ -53,2 +54,3 @@ self.addMatch(new CompleteEqual(Token.HACK, '-webkit-'), null, true);

self.addMatch(new RegMatch(Token.SELECTOR, /^#\w[\w\-]*/i));
self.addMatch(new RegMatch(Token.VARS, /^var-\w+/i));
self.addMatch(new RegMatch(Token.ID, /^[a-z]\w*(?:-\w+)*/i));

@@ -73,3 +75,4 @@ self.addMatch(new RegMatch(Token.STRING, /^(\\[a-z\d]{4})+/i));

'@keyframes': true,
'@namespace': true
'@namespace': true,
'@-moz-document': true
}.hasOwnProperty(s)) {

@@ -93,3 +96,3 @@ token.type(Token.VARS);

KEYWORDS: 'appearance ascent aspect-ratio azimuth backface-visibility background-attachment background-clip background-color background-image background-origin background-position background-repeat background-size background baseline bbox border-collapse border-color border-image border-radius border-spacing border-style border-top border-right border-bottom border-left border-top-color border-right-color border-bottom-color border-left-color border-top-style border-right-style border-bottom-style border-left-style border-top-width border-right-width border-bottom-width border-left-width border-width border-top-left-radius border-bottom-left-radius border-top-right-radius border-bottom-right-radius border bottom box-shadow box-sizing cap-height caption-side centerline clear clip color color-index content counter-increment counter-reset cue-after cue-before cue cursor definition-src descent device-aspect-ratio device-height device-width direction display elevation empty-cells filter float font-size-adjust font-smoothing font-family font-size font-stretch font-style font-variant font-weight font grid height interpolation-mode left letter-spacing line-height list-style-image list-style-position list-style-type list-style margin-top margin-right margin-bottom margin-left margin marker-offset marks mathline max-aspect-ratio max-device-pixel-ratio max-device-width max-height max-width min-aspect-ratio min-device-pixel-ratio min-device-width min-height min-width monochrome nav-down nav-left nav-right nav-up opacity orphans outline-color outline-style outline-width orientation outline overflow-x overflow-y overflow padding-top padding-right padding-bottom padding-left padding page page-break-after page-break-before page-break-inside pause pause-after pause-before pitch pitch-range play-during position quotes resize resolution right richness scan size slope src speak-header speak-numeral speak-punctuation speak speech-rate stemh stemv stress table-layout text-align top text-decoration text-indent text-justify text-overflow text-shadow text-transform transform transform-origin transition transition-property unicode-bidi unicode-range units-per-em vertical-align visibility voice-family volume white-space widows width widths word-break word-spacing word-wrap x-height z-index zoom'.split(' '),
VALUES: 'above absolute all alpha always antialiased aqua armenian attr aural auto avoid background baseline behind below bicubic bidi-override black blink block blue bold bolder border-box both bottom break-all break-word braille capitalize caption center center-left center-right circle close-quote code collapse color compact condensed content-box continuous counter counters crop cross crosshair cursive dashed decimal decimal-leading-zero default digits disc dotted double ease ease-in ease-out ease-in-out embed embossed e-resize expanded extra-condensed extra-expanded fantasy far-left far-right fast faster fixed flipouttoleft flipouttoright flipouttotop flipouttobottom format fuchsia gray grayscale green groove handheld hebrew help hidden hide high higher icon inline-table inline inset inside inter-ideograph invert italic justify landscape large larger left-side leftwards level lighter lime linear-gradient linear line-through list-item local loud lower-alpha lowercase lower-greek lower-latin lower-roman lower low ltr marker maroon medium message-box middle mix move narrower navy ne-resize no-close-quote none no-open-quote no-repeat normal nowrap n-resize nw-resize oblique olive once opacity open-quote outset outside overline padding-box pointer portrait pre print projection purple red relative repeat repeat-x repeat-y rgb ridge right right-side rightwards rotate rotateX rotateY rtl run-in scale screen scroll semi-condensed semi-expanded separate se-resize show silent silver slower slow small small-caps small-caption smaller soft solid speech spell-out square s-resize static status-bar sub super sw-resize table-caption table-cell table-column table-column-group table-footer-group table-header-group table-row table-row-group teal text-bottom text-top text thick thin top transparent translate tty tv ultra-condensed ultra-expanded underline upper-alpha uppercase upper-latin upper-roman url visible wait white wider width w-resize x-fast x-high x-large x-loud x-low x-slow x-small x-soft xx-large xx-small yellow'.split(' '),
VALUES: 'above absolute all alpha always antialiased aqua armenian attr aural auto avoid background baseline behind below bicubic bidi-override black blink block blue bold bolder border-box both bottom break-all break-word braille cal capitalize caption center center-left center-right circle close-quote code collapse color compact condensed content-box continuous counter counters crop cross crosshair cursive dashed decimal decimal-leading-zero default digits disc dotted double ease ease-in ease-out ease-in-out embed embossed e-resize expanded extra-condensed extra-expanded fantasy far-left far-right fast faster fixed flipouttoleft flipouttoright flipouttotop flipouttobottom format fuchsia gray grayscale green groove handheld hebrew help hidden hide high higher icon inline-table inline inset inside inter-ideograph invert italic justify landscape large larger left-side leftwards level lighter lime linear-gradient linear line-through list-item local loud lower-alpha lowercase lower-greek lower-latin lower-roman lower low ltr marker maroon medium message-box middle mix move narrower navy ne-resize no-close-quote none no-open-quote no-repeat normal nowrap n-resize nw-resize oblique olive once opacity open-quote outset outside overline padding-box pointer portrait pre print projection purple red relative repeat repeat-x repeat-y rgb ridge right right-side rightwards rotate rotateX rotateY rtl run-in scale screen scroll semi-condensed semi-expanded separate se-resize show silent silver slower slow small small-caps small-caption smaller soft solid speech spell-out square s-resize static status-bar sub super sw-resize table-caption table-cell table-column table-column-group table-footer-group table-header-group table-row table-row-group teal text-bottom text-top text thick thin top transparent translate tty tv ultra-condensed ultra-expanded underline upper-alpha uppercase upper-latin upper-roman url var visible wait white wider width w-resize x-fast x-high x-large x-loud x-low x-slow x-small x-soft xx-large xx-small yellow'.split(' '),
COLORS: 'black silver gray white maroon red purple fuchsia green lime olive yellow navy blue teal aqua'.split(' ')

@@ -96,0 +99,0 @@ });

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