homunculus
Advanced tools
Comparing version 0.6.0 to 0.6.1
{ | ||
"name": "homunculus", | ||
"version": "0.6.0", | ||
"version": "0.6.1", | ||
"description": "A lexer&parser by Javascript", | ||
@@ -5,0 +5,0 @@ "maintainers": [ |
@@ -193,3 +193,3 @@ var Lexer = require('./Lexer'); | ||
token.type(Token.PROPERTY); | ||
this.url = s == 'url' || s == 'format'; | ||
this.url = ['url', 'format', 'url-prefix', 'domain', 'regexp'].indexOf(s) > -1; | ||
this.var = s == 'var'; | ||
@@ -196,0 +196,0 @@ } |
@@ -129,3 +129,3 @@ var Rule = require('./Rule'); | ||
KEYWORDS: '-replace -set-link-source -use-link-source accelerator additive-symbols align-content align-items align-self alignment-adjust alignment-baseline anchor-point animation animation-delay animation-duration animation-fill-mode animation-iteration-count animation-name animation-play-state animation-timing-function app-region appearance ascent aspect-ratio autohiding-scrollbar azimuth backface-visibility background background-attachment background-clip background-color background-image background-origin background-origin-x background-origin-y background-position background-position-x background-position-y background-repeat background-size baseline baseline-shift behavior binding blend-mode block-progression bookmark-label bookmark-level bookmark-state bookmark-target border border-after border-after-color border-after-style border-after-width border-before border-before-color border-before-style border-before-width border-bottom border-bottom-color border-bottom-colors border-bottom-left-radius border-bottom-right-radius border-bottom-style border-bottom-width border-clip-bottom border-clip-left border-clip-right border-clip-top border-collapse border-color border-fit border-horizontal-spacing border-image border-image-outset border-image-repeat border-image-slice border-image-source border-image-width border-left border-left-color border-left-colors border-left-style border-left-width border-radius border-radius-bottomleft border-radius-bottomright border-radius-topleft border-radius-topright border-right border-right-color border-right-colors border-right-style border-right-width border-spacing border-start border-start-color border-start-style border-start-width border-style border-top border-top-color border-top-colors border-top-left-radius border-top-right-radius border-top-style border-top-width border-vertical-spacing border-width bottom bottom-left-radius bottom-right-radius box box-align box-decoration-break box-direction box-flex box-flex-group box-lines box-ordinal-group box-orient box-pack box-reflect box-shadow box-sizing box-snap break-after break-before break-inside cap-height caption-side centerline chains clear clip clip-path clip-rule color color-correction color-index color-profile column-axis column-break-after column-break-before column-break-inside column-count column-fill column-gap column-progression column-rule column-rule-color column-rule-style column-rule-width column-span column-width columns content content-zoom-chaining content-zoom-limit content-zoom-limit-max content-zoom-limit-min content-zoom-snap content-zoom-snap-points content-zoom-snap-type content-zooming counter-increment counter-reset cue cue-after cue-before cursor dashboard-region definition-src descent device-aspect-ratio device-height device-width direction display display-box display-extras display-inside display-outside dominant-baseline drop-initial-after-adjust drop-initial-after-align drop-initial-before-adjust drop-initial-before-align drop-initial-size drop-initial-value elevation empty-cells fallback fill fill-opacity fill-rule filter fit fit-position flavor flex flex-basis flex-direction flex-flow flex-grow flex-pack flex-shrink flex-wrap float float-edge float-offset flood-color flood-opacity flow-from flow-into focus-ring-color font font-color font-emphasize font-emphasize-position font-emphasize-style font-family font-feature-settings font-kerning font-language-override font-size font-size-adjust font-size-delta font-smooth font-smoothing font-stretch font-style font-synthesis font-variant font-variant-alternates font-variant-caps font-variant-east-asian font-variant-ligatures font-variant-numeric font-variant-position font-weight footnote force-broken-image-icon glyph-orientation-horizontal glyph-orientation-vertical grid grid-area grid-auto-columns grid-auto-flow grid-auto-rows grid-column grid-column-align grid-column-position grid-column-span grid-columns grid-definition-columns grid-definition-rows grid-position grid-row grid-row-align grid-row-position grid-row-span grid-rows grid-span grid-template hanging-punctuation height high-contrast high-contrast-adjust highlight horiz-align hyphenate-character hyphenate-limit-after hyphenate-limit-before hyphenate-limit-chars hyphenate-limit-last hyphenate-limit-lines hyphenate-limit-zone hyphenate-resource hyphens icon image-orientation image-rendering image-resolution images-in-menus ime-mode include-source inherit initial inline-box-align inline-flex inline-table input-format input-required interpolation-mode interpret-as justify-content justify-items justify-self kerning languages layer-background-color layer-background-image layout-flow layout-grid layout-grid-char layout-grid-char-spacing layout-grid-line layout-grid-mode layout-grid-type left letter-spacing lighting-color line-align line-box-contain line-break line-clamp line-grid line-height line-slack line-snap line-stacking line-stacking-ruby line-stacking-shift line-stacking-strategy linear-gradient link link-source list-image-1 list-image-2 list-image-3 list-style list-style-image list-style-position list-style-type locale logical-height logical-width mac-graphite-theme maemo-classic margin margin-after margin-after-collapse margin-before margin-before-collapse margin-bottom margin-bottom-collapse margin-collapse margin-end margin-left margin-right margin-start margin-top margin-top-collapse marker marker-end marker-mid marker-offset marker-start marks marquee marquee-dir marquee-direction marquee-increment marquee-loop marquee-play-count marquee-repetition marquee-speed marquee-style mask mask-attachment mask-box-image mask-box-image-outset mask-box-image-repeat mask-box-image-slice mask-box-image-source mask-box-image-width mask-clip mask-composite mask-image mask-origin mask-position mask-position-x mask-position-y mask-repeat mask-repeat-x mask-repeat-y mask-size mask-type match-nearest-mail-blockquote-color mathline max-aspect-ratio max-color max-color-index max-device-aspect-ratio max-device-height max-device-pixel-ratio max-device-width max-height max-logical-height max-logical-width max-monochrome max-resolution max-width max-zoom min-aspect-ratio min-color min-color-index min-device-aspect-ratio min-device-height min-device-pixel-ratio min-device-width min-height min-logical-height min-logical-width min-monochrome min-resolution min-width min-zoom mini-fold monochrome move-to nav-banner-image nav-bottom nav-down nav-down-shift nav-index nav-left nav-left-shift nav-right nav-right-shift nav-up nav-up-shift navbutton-* nbsp-mode negative none normal object-fit object-position oeb-column-number oeb-page-foot oeb-page-head opacity order orient orientation orphans osx-font-smoothing outline outline-color outline-offset outline-radius outline-radius-bottomleft outline-radius-bottomright outline-radius-topleft outline-radius-topright outline-style outline-width overflow overflow-scrolling overflow-style overflow-x overflow-y pad padding padding-bottom padding-left padding-right padding-top page page-break-after page-break-before page-break-inside page-policy panose-1 pause pause-after pause-before perspective perspective-origin perspective-origin-x perspective-origin-y phonemes pitch pitch-range play-during pointer-events position prefix presentation-level print-color-adjust progress-appearance property-name punctuation-trim punctuation-wrap quotes radial-gradient range region-break-after region-break-before region-break-inside region-overflow rendering-intent replace resize resolution rest rest-after rest-before richness right rotation-point row-span rtl-ordering ruby-align ruby-overhang ruby-position ruby-span scan script-level script-min-size script-size-multiplier scroll-chaining scroll-limit scroll-limit-x-max scroll-limit-x-min scroll-limit-y-max scroll-limit-y-min scroll-rails scroll-snap-points-x scroll-snap-points-y scroll-snap-type scroll-snap-x scroll-snap-y scroll-translation scrollbar-3d-light-color scrollbar-3dlight-color scrollbar-arrow-color scrollbar-base-color scrollbar-dark-shadow-color scrollbar-darkshadow-color scrollbar-end-backward scrollbar-end-forward scrollbar-face-color scrollbar-highlight-color scrollbar-shadow-color scrollbar-start-backward scrollbar-start-forward scrollbar-thumb-proportional scrollbar-track-color separator-image set-link-source shape-image-threshold shape-inside shape-margin shape-outside shape-padding shape-rendering size slope speak speak-as speak-header speak-numeral speak-punctuation speech-rate src stack-sizing stemh stemv stop-color stop-opacity stress string-set stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width suffix svg-shadow symbols system tab-size tab-stops table-baseline table-border-color-dark table-border-color-light table-layout tap-highlight-color target target-name target-new target-position text-align text-align-last text-anchor text-autospace text-blink text-combine text-combine-horizontal text-decoration text-decoration-color text-decoration-line text-decoration-skip text-decoration-style text-decorations-in-effect text-effect text-emphasis text-emphasis-color text-emphasis-position text-emphasis-skip text-emphasis-style text-fill-color text-fit text-height text-indent text-justify text-justify-trim text-kashida text-kashida-space text-line-through text-orientation text-outline text-overflow text-rendering text-security text-shadow text-size-adjust text-space-collapse text-spacing text-stroke text-stroke-color text-stroke-width text-transform text-trim text-underline text-underline-color text-underline-position text-underline-style text-wrap top top-bar-button top-left-radius top-right-radius touch-action touch-callout touch-enabled transform transform-origin transform-origin-x transform-origin-y transform-origin-z transform-style transition transition-delay transition-duration transition-property transition-repeat-count transition-timing-function unicode-bidi unicode-range units-per-em use-link-source user-drag user-focus user-input user-modify user-select user-zoom vector-effect version vertical-align viewport visibility voice-balance voice-duration voice-family voice-pitch voice-pitch-range voice-range voice-rate voice-stress voice-volume volume white-space widows width widths window-shadow windows-classic windows-compositor windows-default-theme word-break word-spacing word-wrap wrap wrap-flow wrap-margin wrap-padding wrap-through writing-mode x-height z-index zoom'.split(' '), | ||
VALUES: 'farthest-corner closest-side closest-corner farthest-side above absolute additive all alpha alphabetic always and antialiased aqua armenian attr aural auto avoid background baseline behind below bicubic bidi-override black blink block blue bold bolder border-box both bottom braille break-all break-word calc canvas capitalize caption center center-left center-right circle cjk-decimal cjk-ideographic close-quote code collapse color compact condensed contain content-box continuous counter counters cover crop cross cross-fade crosshair cubic-bezier cursive cycle cyclic dashed decimal decimal-leading-zero default device-cmyk digits disabled disc disclosure-closed disclosure-open dotted double e-resize ease ease-in ease-in-out ease-out element embed embossed enabled expanded extra-condensed extra-expanded false fantasy far-left far-right fast faster fixed flipouttobottom flipouttoleft flipouttoright flipouttotop format fuchsia georgian gray grayscale green groove handheld hebrew help hidden hide high higher hiragana hiragana-iroha hsl hsla icon image image-rect image-region infinite inherit inline inline-table inset inside inter-ideograph invert italic japanese-formal japanese-informal justify katakana katakana-iroha korean-hangul-formal korean-hanja-formal korean-hanja-informal landscape large larger leader left-side leftwards level lighter lime line-through linear linear-gradient list-item local loud low lower lower-alpha lower-greek lower-latin lower-roman lowercase ltr marker maroon medium message-box middle min max mix move n-resize narrower navy ne-resize no-close-quote no-open-quote no-repeat none normal not nowrap numeric nw-resize oblique olive once only opacity open-quote outset outside overline padding-box pending perspective pointer portrait pre print projection purple rebeccapurple rect red relative repeat repeat-x repeat-y repeating-linear-gradient repeating-radial-gradient rgb rgba ridge right right-side rightwards rotate rotate3d rotateX rotateY rotateZ round rounddown roundup rtl run-in running s-resize scale scale3D scaleX scaleY scaleZ screen scroll se-resize semi-condensed semi-expanded separate show silent silver simp-chinese-formal simp-chinese-informal skew skew3D skewX skewY skewZ slow slower small small-caps small-caption smaller soft solid space speech spell-out square static status-bar steps string sub super sw-resize symbolic symbols table-caption table-cell table-column table-column-group table-footer-group table-header-group table-row table-row-group target-counter target-counters target-pull target-text teal text text-bottom text-top thick thin toggle top trad-chinese-formal trad-chinese-informal translate translate3d translateX translateY translateZ true tty tv ultra-condensed ultra-expanded underline upper-alpha upper-latin upper-roman uppercase url var visible w-resize wait white wider width x-fast x-high x-large x-loud x-low x-slow x-small x-soft xx-large xx-small yellow'.split(' '), | ||
VALUES: 'domain regexp farthest-corner closest-side closest-corner farthest-side above absolute additive all alpha alphabetic always and antialiased aqua armenian attr aural auto avoid background baseline behind below bicubic bidi-override black blink block blue bold bolder border-box both bottom braille break-all break-word calc canvas capitalize caption center center-left center-right circle cjk-decimal cjk-ideographic close-quote code collapse color compact condensed contain content-box continuous counter counters cover crop cross cross-fade crosshair cubic-bezier cursive cycle cyclic dashed decimal decimal-leading-zero default device-cmyk digits disabled disc disclosure-closed disclosure-open dotted double e-resize ease ease-in ease-in-out ease-out element embed embossed enabled expanded extra-condensed extra-expanded false fantasy far-left far-right fast faster fixed flipouttobottom flipouttoleft flipouttoright flipouttotop format fuchsia georgian gray grayscale green groove handheld hebrew help hidden hide high higher hiragana hiragana-iroha hsl hsla icon image image-rect image-region infinite inherit inline inline-table inset inside inter-ideograph invert italic japanese-formal japanese-informal justify katakana katakana-iroha korean-hangul-formal korean-hanja-formal korean-hanja-informal landscape large larger leader left-side leftwards level lighter lime line-through linear linear-gradient list-item local loud low lower lower-alpha lower-greek lower-latin lower-roman lowercase ltr marker maroon medium message-box middle min max mix move n-resize narrower navy ne-resize no-close-quote no-open-quote no-repeat none normal not nowrap numeric nw-resize oblique olive once only opacity open-quote outset outside overline padding-box pending perspective pointer portrait pre print projection purple rebeccapurple rect red relative repeat repeat-x repeat-y repeating-linear-gradient repeating-radial-gradient rgb rgba ridge right right-side rightwards rotate rotate3d rotateX rotateY rotateZ round rounddown roundup rtl run-in running s-resize scale scale3D scaleX scaleY scaleZ screen scroll se-resize semi-condensed semi-expanded separate show silent silver simp-chinese-formal simp-chinese-informal skew skew3D skewX skewY skewZ slow slower small small-caps small-caption smaller soft solid space speech spell-out square static status-bar steps string sub super sw-resize symbolic symbols table-caption table-cell table-column table-column-group table-footer-group table-header-group table-row table-row-group target-counter target-counters target-pull target-text teal text text-bottom text-top thick thin toggle top trad-chinese-formal trad-chinese-informal translate translate3d translateX translateY translateZ true tty tv ultra-condensed ultra-expanded underline upper-alpha upper-latin upper-roman uppercase url url-prefix var visible w-resize wait white wider width x-fast x-high x-large x-loud x-low x-slow x-small x-soft xx-large xx-small yellow'.split(' '), | ||
COLORS: 'transparent activeborder aliceblue antiquewhite appworkspace aqua aqua aquamarine azure beige bisque black black blanchedalmond blue blue blueviolet brown burlywood buttonface buttonshadow cadetblue captiontext chartreuse chocolate coral cornflowerblue cornsilk crimson cyan darkblue darkcyan darkgoldenrod darkgray darkgreen darkgrey darkkhaki darkmagenta darkolivegreen darkorange darkorchid darkred darksalmon darkseagreen darkslateblue darkslategray darkslategrey darkturquoise darkviolet deeppink deepskyblue dimgray dimgrey dodgerblue firebrick floralwhite forestgreen fuchsia fuchsia gainsboro ghostwhite gold goldenrod gray gray green green greenyellow grey highlight honeydew hotpink inactiveborder inactivecaptiontext indianred indigo infotext ivory khaki lavender lavenderblush lawngreen lemonchiffon lightblue lightcoral lightcyan lightgoldenrodyellow lightgray lightgreen lightgrey lightpink lightsalmon lightseagreen lightskyblue lightslategray lightslategrey lightsteelblue lightyellow lime lime limegreen linen magenta maroon maroon mediumaquamarine mediumblue mediumorchid mediumpurple mediumseagreen mediumslateblue mediumspringgreen mediumturquoise mediumvioletred menutext midnightblue mintcream mistyrose moccasin navajowhite navy navy oldlace olive olive olivedrab orange orangered orchid palegoldenrod palegreen paleturquoise palevioletred papayawhip peachpuff peru pink plum powderblue purple purple red red rosybrown royalblue saddlebrown salmon sandybrown seagreen seashell sienna silver silver skyblue slateblue slategray slategrey snow springgreen steelblue tan teal teal thistle threeddarkshadow threedhighlight threedshadow tomato turquoise violet wheat white white whitesmoke windowframe yellow yellow yellowgreen'.split(' '), | ||
@@ -132,0 +132,0 @@ addKeyWord: function(kw) { |
@@ -64,2 +64,5 @@ var INode = require('../Node'); | ||
BRACKET: 'bracket', | ||
URLPREFIX: 'ulrprefix', | ||
DOMAIN: 'domain', | ||
REGEXP: 'regexp', | ||
getKey: function(s) { | ||
@@ -66,0 +69,0 @@ if(!s) { |
@@ -101,2 +101,3 @@ var IParser = require('../Parser'); | ||
case Token.SELECTOR: | ||
case Token.PSEUDO: | ||
return this.styleset(); | ||
@@ -107,2 +108,5 @@ default: | ||
} | ||
if(['{', '}'].indexOf(this.look.content()) > -1) { | ||
this.error(); | ||
} | ||
return this.match(); | ||
@@ -159,3 +163,3 @@ } | ||
} | ||
node.add(this.sheet()); | ||
node.add(this.block()); | ||
return node; | ||
@@ -183,3 +187,3 @@ }, | ||
default: | ||
node.add(this.style(null, true, true)); | ||
node.add(this.style(null, true)); | ||
break; | ||
@@ -436,24 +440,35 @@ } | ||
var node = new Node(Node.DOC); | ||
node.add( | ||
this.match(), | ||
this.match([Token.ID, Token.PROPERTY]), | ||
this.match('(') | ||
); | ||
if(this.look | ||
&& (this.look.type() == Token.STRING | ||
|| this.look.type() == Token.VARS)) { | ||
node.add(this.addexpr(Token.STRING)); | ||
node.add(this.match()); | ||
if(!this.look) { | ||
this.error(); | ||
} | ||
node.add(this.match(')')); | ||
switch(this.look.content().toLowerCase()) { | ||
case 'url-prefix': | ||
case 'domain': | ||
case 'regexp': | ||
node.add(this.urlPrefix(this.look.content().toUpperCase().replace('-', ''))); | ||
break; | ||
case 'url': | ||
node.add(this.url()); | ||
break; | ||
default: | ||
this.error(); | ||
} | ||
while(this.look && this.look.content() == ',') { | ||
node.add( | ||
this.match(), | ||
this.match([Token.ID, Token.PROPERTY]), | ||
this.match('(') | ||
); | ||
if(this.look | ||
&& (this.look.type() == Token.STRING | ||
|| this.look.type() == Token.VARS)) { | ||
node.add(this.addexpr(Token.STRING)); | ||
node.add(this.match()); | ||
if(!this.look) { | ||
this.error(); | ||
} | ||
switch(this.look.content().toLowerCase()) { | ||
case 'url-prefix': | ||
case 'domain': | ||
case 'regexp': | ||
node.add(this.urlPrefix(this.look.content().toUpperCase().replace('-', ''))); | ||
break; | ||
case 'url': | ||
node.add(this.url()); | ||
break; | ||
default: | ||
this.error(); | ||
} | ||
} | ||
@@ -465,2 +480,14 @@ if(this.look && this.look.content() == '{') { | ||
}, | ||
urlPrefix: function(name) { | ||
var node = new Node(Node[name]); | ||
node.add( | ||
this.match(), | ||
this.match('(') | ||
); | ||
if(this.look && this.look.content() != ')') { | ||
node.add(this.addexpr(Token.STRING)); | ||
} | ||
node.add(this.match(')')); | ||
return node; | ||
}, | ||
vardecl: function() { | ||
@@ -482,3 +509,3 @@ var node = new Node(Node.VARDECL); | ||
if(this.look.type() == Token.KEYWORD) { | ||
node.add(this.style(null, null, true)); | ||
node.add(this.style(null, true)); | ||
} | ||
@@ -494,2 +521,10 @@ else { | ||
node.add(this.selectors(kf)); | ||
//兼容less的继承写法,即只写一个选择器 | ||
if(this.look && [';', '}'].indexOf(this.look.content()) > -1) { | ||
node.name(Node.EXTEND); | ||
var extend = new Token(Token.VIRTUAL, '@extend'); | ||
extend = new Node(Node.TOKEN, extend); | ||
node.addFirst(extend); | ||
return node; | ||
} | ||
node.add(this.block()); | ||
@@ -561,2 +596,3 @@ return node; | ||
var isFnCall = false; | ||
var isDecl = false; | ||
for(var i = this.index; i < this.length; i++) { | ||
@@ -566,2 +602,3 @@ var t = this.tokens[i]; | ||
isFnCall = t.content() == '('; | ||
isDecl = [':', '='].indexOf(t.content()) > -1; | ||
break; | ||
@@ -573,2 +610,5 @@ } | ||
} | ||
else if(isDecl) { | ||
node.add(this.vardecl()); | ||
} | ||
else { | ||
@@ -594,3 +634,3 @@ node.add(this.addexpr()); | ||
}, | ||
style: function(name, noP, noS) { | ||
style: function(name, noS) { | ||
var node = new Node(Node.STYLE); | ||
@@ -870,3 +910,3 @@ var k = this.key(name); | ||
} | ||
else if(['left', 'center', 'right'].indexOf(this.look.content().toLowerCase()) > -1){ | ||
else if(['top', 'center', 'bottom'].indexOf(this.look.content().toLowerCase()) > -1){ | ||
node.add(this.match()); | ||
@@ -932,3 +972,3 @@ } | ||
} | ||
node.add(this.match(['left', 'right', 'top', 'bottom'])); | ||
node.add(this.match(['left', 'right', 'top', 'bottom', 'center'])); | ||
if(this.look && this.look.content().toLowerCase() == 'to') { | ||
@@ -938,3 +978,3 @@ node.add(this.match()); | ||
if(this.look && this.look.type() == Token.PROPERTY) { | ||
node.add(this.match(['left', 'right', 'top', 'bottom'])); | ||
node.add(this.match(['left', 'right', 'top', 'bottom', 'center'])); | ||
} | ||
@@ -1154,6 +1194,8 @@ } | ||
this.match('url'), | ||
this.match('('), | ||
this.addexpr(Token.STRING), | ||
this.match(')') | ||
this.match('(') | ||
); | ||
if(this.look && this.look.content() != ')') { | ||
node.add(this.addexpr(Token.STRING)); | ||
} | ||
node.add(this.match(')')); | ||
} | ||
@@ -1244,3 +1286,3 @@ return node; | ||
node.add( | ||
this.match(), | ||
this.match([Token.ID, Token.PROPERTY]), | ||
this.match('(') | ||
@@ -1247,0 +1289,0 @@ ); |
@@ -75,2 +75,29 @@ var Class = require('../util/Class'); | ||
}, | ||
addFirst: function() { | ||
var self = this; | ||
var args = Array.prototype.slice.call(arguments, 0); | ||
args.forEach(function(node) { | ||
if(Array.isArray(node)) { | ||
node.forEach(function(node2) { | ||
node2.parent(self); | ||
var last = self.children[0]; | ||
if(last) { | ||
last.next(node2); | ||
node2.prev(last); | ||
} | ||
self.children.unshift(node2); | ||
}); | ||
} | ||
else { | ||
node.parent(self); | ||
var last = self.children[0]; | ||
if(last) { | ||
last.next(node); | ||
node.prev(last); | ||
} | ||
self.children.unshift(node); | ||
} | ||
}); | ||
return self; | ||
}, | ||
token: function() { | ||
@@ -77,0 +104,0 @@ return this.children; |
@@ -193,3 +193,3 @@ define(function(require, exports, module) {var Lexer = require('./Lexer'); | ||
token.type(Token.PROPERTY); | ||
this.url = s == 'url' || s == 'format'; | ||
this.url = ['url', 'format', 'url-prefix', 'domain', 'regexp'].indexOf(s) > -1; | ||
this.var = s == 'var'; | ||
@@ -196,0 +196,0 @@ } |
@@ -129,3 +129,3 @@ define(function(require, exports, module) {var Rule = require('./Rule'); | ||
KEYWORDS: '-replace -set-link-source -use-link-source accelerator additive-symbols align-content align-items align-self alignment-adjust alignment-baseline anchor-point animation animation-delay animation-duration animation-fill-mode animation-iteration-count animation-name animation-play-state animation-timing-function app-region appearance ascent aspect-ratio autohiding-scrollbar azimuth backface-visibility background background-attachment background-clip background-color background-image background-origin background-origin-x background-origin-y background-position background-position-x background-position-y background-repeat background-size baseline baseline-shift behavior binding blend-mode block-progression bookmark-label bookmark-level bookmark-state bookmark-target border border-after border-after-color border-after-style border-after-width border-before border-before-color border-before-style border-before-width border-bottom border-bottom-color border-bottom-colors border-bottom-left-radius border-bottom-right-radius border-bottom-style border-bottom-width border-clip-bottom border-clip-left border-clip-right border-clip-top border-collapse border-color border-fit border-horizontal-spacing border-image border-image-outset border-image-repeat border-image-slice border-image-source border-image-width border-left border-left-color border-left-colors border-left-style border-left-width border-radius border-radius-bottomleft border-radius-bottomright border-radius-topleft border-radius-topright border-right border-right-color border-right-colors border-right-style border-right-width border-spacing border-start border-start-color border-start-style border-start-width border-style border-top border-top-color border-top-colors border-top-left-radius border-top-right-radius border-top-style border-top-width border-vertical-spacing border-width bottom bottom-left-radius bottom-right-radius box box-align box-decoration-break box-direction box-flex box-flex-group box-lines box-ordinal-group box-orient box-pack box-reflect box-shadow box-sizing box-snap break-after break-before break-inside cap-height caption-side centerline chains clear clip clip-path clip-rule color color-correction color-index color-profile column-axis column-break-after column-break-before column-break-inside column-count column-fill column-gap column-progression column-rule column-rule-color column-rule-style column-rule-width column-span column-width columns content content-zoom-chaining content-zoom-limit content-zoom-limit-max content-zoom-limit-min content-zoom-snap content-zoom-snap-points content-zoom-snap-type content-zooming counter-increment counter-reset cue cue-after cue-before cursor dashboard-region definition-src descent device-aspect-ratio device-height device-width direction display display-box display-extras display-inside display-outside dominant-baseline drop-initial-after-adjust drop-initial-after-align drop-initial-before-adjust drop-initial-before-align drop-initial-size drop-initial-value elevation empty-cells fallback fill fill-opacity fill-rule filter fit fit-position flavor flex flex-basis flex-direction flex-flow flex-grow flex-pack flex-shrink flex-wrap float float-edge float-offset flood-color flood-opacity flow-from flow-into focus-ring-color font font-color font-emphasize font-emphasize-position font-emphasize-style font-family font-feature-settings font-kerning font-language-override font-size font-size-adjust font-size-delta font-smooth font-smoothing font-stretch font-style font-synthesis font-variant font-variant-alternates font-variant-caps font-variant-east-asian font-variant-ligatures font-variant-numeric font-variant-position font-weight footnote force-broken-image-icon glyph-orientation-horizontal glyph-orientation-vertical grid grid-area grid-auto-columns grid-auto-flow grid-auto-rows grid-column grid-column-align grid-column-position grid-column-span grid-columns grid-definition-columns grid-definition-rows grid-position grid-row grid-row-align grid-row-position grid-row-span grid-rows grid-span grid-template hanging-punctuation height high-contrast high-contrast-adjust highlight horiz-align hyphenate-character hyphenate-limit-after hyphenate-limit-before hyphenate-limit-chars hyphenate-limit-last hyphenate-limit-lines hyphenate-limit-zone hyphenate-resource hyphens icon image-orientation image-rendering image-resolution images-in-menus ime-mode include-source inherit initial inline-box-align inline-flex inline-table input-format input-required interpolation-mode interpret-as justify-content justify-items justify-self kerning languages layer-background-color layer-background-image layout-flow layout-grid layout-grid-char layout-grid-char-spacing layout-grid-line layout-grid-mode layout-grid-type left letter-spacing lighting-color line-align line-box-contain line-break line-clamp line-grid line-height line-slack line-snap line-stacking line-stacking-ruby line-stacking-shift line-stacking-strategy linear-gradient link link-source list-image-1 list-image-2 list-image-3 list-style list-style-image list-style-position list-style-type locale logical-height logical-width mac-graphite-theme maemo-classic margin margin-after margin-after-collapse margin-before margin-before-collapse margin-bottom margin-bottom-collapse margin-collapse margin-end margin-left margin-right margin-start margin-top margin-top-collapse marker marker-end marker-mid marker-offset marker-start marks marquee marquee-dir marquee-direction marquee-increment marquee-loop marquee-play-count marquee-repetition marquee-speed marquee-style mask mask-attachment mask-box-image mask-box-image-outset mask-box-image-repeat mask-box-image-slice mask-box-image-source mask-box-image-width mask-clip mask-composite mask-image mask-origin mask-position mask-position-x mask-position-y mask-repeat mask-repeat-x mask-repeat-y mask-size mask-type match-nearest-mail-blockquote-color mathline max-aspect-ratio max-color max-color-index max-device-aspect-ratio max-device-height max-device-pixel-ratio max-device-width max-height max-logical-height max-logical-width max-monochrome max-resolution max-width max-zoom min-aspect-ratio min-color min-color-index min-device-aspect-ratio min-device-height min-device-pixel-ratio min-device-width min-height min-logical-height min-logical-width min-monochrome min-resolution min-width min-zoom mini-fold monochrome move-to nav-banner-image nav-bottom nav-down nav-down-shift nav-index nav-left nav-left-shift nav-right nav-right-shift nav-up nav-up-shift navbutton-* nbsp-mode negative none normal object-fit object-position oeb-column-number oeb-page-foot oeb-page-head opacity order orient orientation orphans osx-font-smoothing outline outline-color outline-offset outline-radius outline-radius-bottomleft outline-radius-bottomright outline-radius-topleft outline-radius-topright outline-style outline-width overflow overflow-scrolling overflow-style overflow-x overflow-y pad padding padding-bottom padding-left padding-right padding-top page page-break-after page-break-before page-break-inside page-policy panose-1 pause pause-after pause-before perspective perspective-origin perspective-origin-x perspective-origin-y phonemes pitch pitch-range play-during pointer-events position prefix presentation-level print-color-adjust progress-appearance property-name punctuation-trim punctuation-wrap quotes radial-gradient range region-break-after region-break-before region-break-inside region-overflow rendering-intent replace resize resolution rest rest-after rest-before richness right rotation-point row-span rtl-ordering ruby-align ruby-overhang ruby-position ruby-span scan script-level script-min-size script-size-multiplier scroll-chaining scroll-limit scroll-limit-x-max scroll-limit-x-min scroll-limit-y-max scroll-limit-y-min scroll-rails scroll-snap-points-x scroll-snap-points-y scroll-snap-type scroll-snap-x scroll-snap-y scroll-translation scrollbar-3d-light-color scrollbar-3dlight-color scrollbar-arrow-color scrollbar-base-color scrollbar-dark-shadow-color scrollbar-darkshadow-color scrollbar-end-backward scrollbar-end-forward scrollbar-face-color scrollbar-highlight-color scrollbar-shadow-color scrollbar-start-backward scrollbar-start-forward scrollbar-thumb-proportional scrollbar-track-color separator-image set-link-source shape-image-threshold shape-inside shape-margin shape-outside shape-padding shape-rendering size slope speak speak-as speak-header speak-numeral speak-punctuation speech-rate src stack-sizing stemh stemv stop-color stop-opacity stress string-set stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width suffix svg-shadow symbols system tab-size tab-stops table-baseline table-border-color-dark table-border-color-light table-layout tap-highlight-color target target-name target-new target-position text-align text-align-last text-anchor text-autospace text-blink text-combine text-combine-horizontal text-decoration text-decoration-color text-decoration-line text-decoration-skip text-decoration-style text-decorations-in-effect text-effect text-emphasis text-emphasis-color text-emphasis-position text-emphasis-skip text-emphasis-style text-fill-color text-fit text-height text-indent text-justify text-justify-trim text-kashida text-kashida-space text-line-through text-orientation text-outline text-overflow text-rendering text-security text-shadow text-size-adjust text-space-collapse text-spacing text-stroke text-stroke-color text-stroke-width text-transform text-trim text-underline text-underline-color text-underline-position text-underline-style text-wrap top top-bar-button top-left-radius top-right-radius touch-action touch-callout touch-enabled transform transform-origin transform-origin-x transform-origin-y transform-origin-z transform-style transition transition-delay transition-duration transition-property transition-repeat-count transition-timing-function unicode-bidi unicode-range units-per-em use-link-source user-drag user-focus user-input user-modify user-select user-zoom vector-effect version vertical-align viewport visibility voice-balance voice-duration voice-family voice-pitch voice-pitch-range voice-range voice-rate voice-stress voice-volume volume white-space widows width widths window-shadow windows-classic windows-compositor windows-default-theme word-break word-spacing word-wrap wrap wrap-flow wrap-margin wrap-padding wrap-through writing-mode x-height z-index zoom'.split(' '), | ||
VALUES: 'farthest-corner closest-side closest-corner farthest-side above absolute additive all alpha alphabetic always and antialiased aqua armenian attr aural auto avoid background baseline behind below bicubic bidi-override black blink block blue bold bolder border-box both bottom braille break-all break-word calc canvas capitalize caption center center-left center-right circle cjk-decimal cjk-ideographic close-quote code collapse color compact condensed contain content-box continuous counter counters cover crop cross cross-fade crosshair cubic-bezier cursive cycle cyclic dashed decimal decimal-leading-zero default device-cmyk digits disabled disc disclosure-closed disclosure-open dotted double e-resize ease ease-in ease-in-out ease-out element embed embossed enabled expanded extra-condensed extra-expanded false fantasy far-left far-right fast faster fixed flipouttobottom flipouttoleft flipouttoright flipouttotop format fuchsia georgian gray grayscale green groove handheld hebrew help hidden hide high higher hiragana hiragana-iroha hsl hsla icon image image-rect image-region infinite inherit inline inline-table inset inside inter-ideograph invert italic japanese-formal japanese-informal justify katakana katakana-iroha korean-hangul-formal korean-hanja-formal korean-hanja-informal landscape large larger leader left-side leftwards level lighter lime line-through linear linear-gradient list-item local loud low lower lower-alpha lower-greek lower-latin lower-roman lowercase ltr marker maroon medium message-box middle min max mix move n-resize narrower navy ne-resize no-close-quote no-open-quote no-repeat none normal not nowrap numeric nw-resize oblique olive once only opacity open-quote outset outside overline padding-box pending perspective pointer portrait pre print projection purple rebeccapurple rect red relative repeat repeat-x repeat-y repeating-linear-gradient repeating-radial-gradient rgb rgba ridge right right-side rightwards rotate rotate3d rotateX rotateY rotateZ round rounddown roundup rtl run-in running s-resize scale scale3D scaleX scaleY scaleZ screen scroll se-resize semi-condensed semi-expanded separate show silent silver simp-chinese-formal simp-chinese-informal skew skew3D skewX skewY skewZ slow slower small small-caps small-caption smaller soft solid space speech spell-out square static status-bar steps string sub super sw-resize symbolic symbols table-caption table-cell table-column table-column-group table-footer-group table-header-group table-row table-row-group target-counter target-counters target-pull target-text teal text text-bottom text-top thick thin toggle top trad-chinese-formal trad-chinese-informal translate translate3d translateX translateY translateZ true tty tv ultra-condensed ultra-expanded underline upper-alpha upper-latin upper-roman uppercase url var visible w-resize wait white wider width x-fast x-high x-large x-loud x-low x-slow x-small x-soft xx-large xx-small yellow'.split(' '), | ||
VALUES: 'domain regexp farthest-corner closest-side closest-corner farthest-side above absolute additive all alpha alphabetic always and antialiased aqua armenian attr aural auto avoid background baseline behind below bicubic bidi-override black blink block blue bold bolder border-box both bottom braille break-all break-word calc canvas capitalize caption center center-left center-right circle cjk-decimal cjk-ideographic close-quote code collapse color compact condensed contain content-box continuous counter counters cover crop cross cross-fade crosshair cubic-bezier cursive cycle cyclic dashed decimal decimal-leading-zero default device-cmyk digits disabled disc disclosure-closed disclosure-open dotted double e-resize ease ease-in ease-in-out ease-out element embed embossed enabled expanded extra-condensed extra-expanded false fantasy far-left far-right fast faster fixed flipouttobottom flipouttoleft flipouttoright flipouttotop format fuchsia georgian gray grayscale green groove handheld hebrew help hidden hide high higher hiragana hiragana-iroha hsl hsla icon image image-rect image-region infinite inherit inline inline-table inset inside inter-ideograph invert italic japanese-formal japanese-informal justify katakana katakana-iroha korean-hangul-formal korean-hanja-formal korean-hanja-informal landscape large larger leader left-side leftwards level lighter lime line-through linear linear-gradient list-item local loud low lower lower-alpha lower-greek lower-latin lower-roman lowercase ltr marker maroon medium message-box middle min max mix move n-resize narrower navy ne-resize no-close-quote no-open-quote no-repeat none normal not nowrap numeric nw-resize oblique olive once only opacity open-quote outset outside overline padding-box pending perspective pointer portrait pre print projection purple rebeccapurple rect red relative repeat repeat-x repeat-y repeating-linear-gradient repeating-radial-gradient rgb rgba ridge right right-side rightwards rotate rotate3d rotateX rotateY rotateZ round rounddown roundup rtl run-in running s-resize scale scale3D scaleX scaleY scaleZ screen scroll se-resize semi-condensed semi-expanded separate show silent silver simp-chinese-formal simp-chinese-informal skew skew3D skewX skewY skewZ slow slower small small-caps small-caption smaller soft solid space speech spell-out square static status-bar steps string sub super sw-resize symbolic symbols table-caption table-cell table-column table-column-group table-footer-group table-header-group table-row table-row-group target-counter target-counters target-pull target-text teal text text-bottom text-top thick thin toggle top trad-chinese-formal trad-chinese-informal translate translate3d translateX translateY translateZ true tty tv ultra-condensed ultra-expanded underline upper-alpha upper-latin upper-roman uppercase url url-prefix var visible w-resize wait white wider width x-fast x-high x-large x-loud x-low x-slow x-small x-soft xx-large xx-small yellow'.split(' '), | ||
COLORS: 'transparent activeborder aliceblue antiquewhite appworkspace aqua aqua aquamarine azure beige bisque black black blanchedalmond blue blue blueviolet brown burlywood buttonface buttonshadow cadetblue captiontext chartreuse chocolate coral cornflowerblue cornsilk crimson cyan darkblue darkcyan darkgoldenrod darkgray darkgreen darkgrey darkkhaki darkmagenta darkolivegreen darkorange darkorchid darkred darksalmon darkseagreen darkslateblue darkslategray darkslategrey darkturquoise darkviolet deeppink deepskyblue dimgray dimgrey dodgerblue firebrick floralwhite forestgreen fuchsia fuchsia gainsboro ghostwhite gold goldenrod gray gray green green greenyellow grey highlight honeydew hotpink inactiveborder inactivecaptiontext indianred indigo infotext ivory khaki lavender lavenderblush lawngreen lemonchiffon lightblue lightcoral lightcyan lightgoldenrodyellow lightgray lightgreen lightgrey lightpink lightsalmon lightseagreen lightskyblue lightslategray lightslategrey lightsteelblue lightyellow lime lime limegreen linen magenta maroon maroon mediumaquamarine mediumblue mediumorchid mediumpurple mediumseagreen mediumslateblue mediumspringgreen mediumturquoise mediumvioletred menutext midnightblue mintcream mistyrose moccasin navajowhite navy navy oldlace olive olive olivedrab orange orangered orchid palegoldenrod palegreen paleturquoise palevioletred papayawhip peachpuff peru pink plum powderblue purple purple red red rosybrown royalblue saddlebrown salmon sandybrown seagreen seashell sienna silver silver skyblue slateblue slategray slategrey snow springgreen steelblue tan teal teal thistle threeddarkshadow threedhighlight threedshadow tomato turquoise violet wheat white white whitesmoke windowframe yellow yellow yellowgreen'.split(' '), | ||
@@ -132,0 +132,0 @@ addKeyWord: function(kw) { |
@@ -64,2 +64,5 @@ define(function(require, exports, module) {var INode = require('../Node'); | ||
BRACKET: 'bracket', | ||
URLPREFIX: 'ulrprefix', | ||
DOMAIN: 'domain', | ||
REGEXP: 'regexp', | ||
getKey: function(s) { | ||
@@ -66,0 +69,0 @@ if(!s) { |
@@ -101,2 +101,3 @@ define(function(require, exports, module) {var IParser = require('../Parser'); | ||
case Token.SELECTOR: | ||
case Token.PSEUDO: | ||
return this.styleset(); | ||
@@ -107,2 +108,5 @@ default: | ||
} | ||
if(['{', '}'].indexOf(this.look.content()) > -1) { | ||
this.error(); | ||
} | ||
return this.match(); | ||
@@ -159,3 +163,3 @@ } | ||
} | ||
node.add(this.sheet()); | ||
node.add(this.block()); | ||
return node; | ||
@@ -183,3 +187,3 @@ }, | ||
default: | ||
node.add(this.style(null, true, true)); | ||
node.add(this.style(null, true)); | ||
break; | ||
@@ -436,24 +440,35 @@ } | ||
var node = new Node(Node.DOC); | ||
node.add( | ||
this.match(), | ||
this.match([Token.ID, Token.PROPERTY]), | ||
this.match('(') | ||
); | ||
if(this.look | ||
&& (this.look.type() == Token.STRING | ||
|| this.look.type() == Token.VARS)) { | ||
node.add(this.addexpr(Token.STRING)); | ||
node.add(this.match()); | ||
if(!this.look) { | ||
this.error(); | ||
} | ||
node.add(this.match(')')); | ||
switch(this.look.content().toLowerCase()) { | ||
case 'url-prefix': | ||
case 'domain': | ||
case 'regexp': | ||
node.add(this.urlPrefix(this.look.content().toUpperCase().replace('-', ''))); | ||
break; | ||
case 'url': | ||
node.add(this.url()); | ||
break; | ||
default: | ||
this.error(); | ||
} | ||
while(this.look && this.look.content() == ',') { | ||
node.add( | ||
this.match(), | ||
this.match([Token.ID, Token.PROPERTY]), | ||
this.match('(') | ||
); | ||
if(this.look | ||
&& (this.look.type() == Token.STRING | ||
|| this.look.type() == Token.VARS)) { | ||
node.add(this.addexpr(Token.STRING)); | ||
node.add(this.match()); | ||
if(!this.look) { | ||
this.error(); | ||
} | ||
switch(this.look.content().toLowerCase()) { | ||
case 'url-prefix': | ||
case 'domain': | ||
case 'regexp': | ||
node.add(this.urlPrefix(this.look.content().toUpperCase().replace('-', ''))); | ||
break; | ||
case 'url': | ||
node.add(this.url()); | ||
break; | ||
default: | ||
this.error(); | ||
} | ||
} | ||
@@ -465,2 +480,14 @@ if(this.look && this.look.content() == '{') { | ||
}, | ||
urlPrefix: function(name) { | ||
var node = new Node(Node[name]); | ||
node.add( | ||
this.match(), | ||
this.match('(') | ||
); | ||
if(this.look && this.look.content() != ')') { | ||
node.add(this.addexpr(Token.STRING)); | ||
} | ||
node.add(this.match(')')); | ||
return node; | ||
}, | ||
vardecl: function() { | ||
@@ -482,3 +509,3 @@ var node = new Node(Node.VARDECL); | ||
if(this.look.type() == Token.KEYWORD) { | ||
node.add(this.style(null, null, true)); | ||
node.add(this.style(null, true)); | ||
} | ||
@@ -494,2 +521,10 @@ else { | ||
node.add(this.selectors(kf)); | ||
//兼容less的继承写法,即只写一个选择器 | ||
if(this.look && [';', '}'].indexOf(this.look.content()) > -1) { | ||
node.name(Node.EXTEND); | ||
var extend = new Token(Token.VIRTUAL, '@extend'); | ||
extend = new Node(Node.TOKEN, extend); | ||
node.addFirst(extend); | ||
return node; | ||
} | ||
node.add(this.block()); | ||
@@ -561,2 +596,3 @@ return node; | ||
var isFnCall = false; | ||
var isDecl = false; | ||
for(var i = this.index; i < this.length; i++) { | ||
@@ -566,2 +602,3 @@ var t = this.tokens[i]; | ||
isFnCall = t.content() == '('; | ||
isDecl = [':', '='].indexOf(t.content()) > -1; | ||
break; | ||
@@ -573,2 +610,5 @@ } | ||
} | ||
else if(isDecl) { | ||
node.add(this.vardecl()); | ||
} | ||
else { | ||
@@ -594,3 +634,3 @@ node.add(this.addexpr()); | ||
}, | ||
style: function(name, noP, noS) { | ||
style: function(name, noS) { | ||
var node = new Node(Node.STYLE); | ||
@@ -870,3 +910,3 @@ var k = this.key(name); | ||
} | ||
else if(['left', 'center', 'right'].indexOf(this.look.content().toLowerCase()) > -1){ | ||
else if(['top', 'center', 'bottom'].indexOf(this.look.content().toLowerCase()) > -1){ | ||
node.add(this.match()); | ||
@@ -932,3 +972,3 @@ } | ||
} | ||
node.add(this.match(['left', 'right', 'top', 'bottom'])); | ||
node.add(this.match(['left', 'right', 'top', 'bottom', 'center'])); | ||
if(this.look && this.look.content().toLowerCase() == 'to') { | ||
@@ -938,3 +978,3 @@ node.add(this.match()); | ||
if(this.look && this.look.type() == Token.PROPERTY) { | ||
node.add(this.match(['left', 'right', 'top', 'bottom'])); | ||
node.add(this.match(['left', 'right', 'top', 'bottom', 'center'])); | ||
} | ||
@@ -1154,6 +1194,8 @@ } | ||
this.match('url'), | ||
this.match('('), | ||
this.addexpr(Token.STRING), | ||
this.match(')') | ||
this.match('(') | ||
); | ||
if(this.look && this.look.content() != ')') { | ||
node.add(this.addexpr(Token.STRING)); | ||
} | ||
node.add(this.match(')')); | ||
} | ||
@@ -1244,3 +1286,3 @@ return node; | ||
node.add( | ||
this.match(), | ||
this.match([Token.ID, Token.PROPERTY]), | ||
this.match('(') | ||
@@ -1247,0 +1289,0 @@ ); |
@@ -75,2 +75,29 @@ define(function(require, exports, module) {var Class = require('../util/Class'); | ||
}, | ||
addFirst: function() { | ||
var self = this; | ||
var args = Array.prototype.slice.call(arguments, 0); | ||
args.forEach(function(node) { | ||
if(Array.isArray(node)) { | ||
node.forEach(function(node2) { | ||
node2.parent(self); | ||
var last = self.children[0]; | ||
if(last) { | ||
last.next(node2); | ||
node2.prev(last); | ||
} | ||
self.children.unshift(node2); | ||
}); | ||
} | ||
else { | ||
node.parent(self); | ||
var last = self.children[0]; | ||
if(last) { | ||
last.next(node); | ||
node.prev(last); | ||
} | ||
self.children.unshift(node); | ||
} | ||
}); | ||
return self; | ||
}, | ||
token: function() { | ||
@@ -77,0 +104,0 @@ return this.children; |
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
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
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
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
16115
543594