Skip to content

Use simple lexical analysis instead of regex #47

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/build-exports.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var makeComposition = require('./composition').makeComposition;
module.exports = function createExports(classes, keyframes, compositions) {
var keyframesObj = Object.keys(keyframes).reduce(function(acc, key) {
var val = keyframes[key];
acc[val] = makeComposition([key], [val], true);
acc[key] = makeComposition([val], [key], true);
return acc;
}, {});

Expand Down
13 changes: 6 additions & 7 deletions lib/csjs.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
'use strict';

var extractExtends = require('./css-extract-extends');
var isComposition = require('./composition').isComposition;
var buildExports = require('./build-exports');
var scopify = require('./scopeify');
var scopify = require('./scopify');
var cssKey = require('./css-key');
var lex = require('./lexer');

module.exports = function csjsHandler(strings) {
// Fast path to prevent arguments deopt
Expand All @@ -23,21 +23,20 @@ module.exports = function csjsHandler(strings) {
return acc;
}, {});

var scoped = scopify(css, ignores);
var hashes = Object.assign({}, scoped.classes, scoped.keyframes);
var extracted = extractExtends(scoped.css, hashes);
var tokens = lex(css);
var scoped = scopify(css, tokens, ignores);

var localClasses = without(scoped.classes, ignores);
var localKeyframes = without(scoped.keyframes, ignores);
var compositions = extracted.compositions;
var compositions = scoped.compositions;

var exports = buildExports(localClasses, localKeyframes, compositions);

return Object.defineProperty(exports, cssKey, {
enumerable: false,
configurable: false,
writeable: false,
value: extracted.css
value: scoped.css
});
};

Expand Down
51 changes: 0 additions & 51 deletions lib/css-extract-extends.js

This file was deleted.

Loading