Finishing tests for Regexper module
This commit is contained in:
@@ -36,8 +36,11 @@ parser.Parser.RepeatOptional = RepeatOptional;
|
||||
parser.Parser.RepeatRequired = RepeatRequired;
|
||||
parser.Parser.RepeatSpec = RepeatSpec;
|
||||
|
||||
parser.resetGroupCounter = () => {
|
||||
parser.Parser.Subexp.resetCounter();
|
||||
}
|
||||
parser.parse = (parse => {
|
||||
return function() {
|
||||
Subexp.resetCounter();
|
||||
return parse.apply(this, arguments);
|
||||
};
|
||||
})(parser.parse);
|
||||
|
||||
export default parser;
|
||||
|
||||
+5
-10
@@ -125,11 +125,7 @@ export default class Regexper {
|
||||
}
|
||||
|
||||
renderRegexp(expression) {
|
||||
var snap = Snap(this.svg);
|
||||
|
||||
snap.selectAll('g').remove();
|
||||
|
||||
parser.resetGroupCounter();
|
||||
this.snap.selectAll('g').remove();
|
||||
|
||||
return Q.fcall(parser.parse.bind(parser), expression.replace(/\n/g, '\\n'))
|
||||
.then(null, message => {
|
||||
@@ -139,14 +135,13 @@ export default class Regexper {
|
||||
|
||||
throw message;
|
||||
})
|
||||
.invoke('render', snap.group())
|
||||
.invoke('render', this.snap.group())
|
||||
.then(result => {
|
||||
var box;
|
||||
var box = result.getBBox();
|
||||
|
||||
box = result.getBBox();
|
||||
result.container.transform(Snap.matrix()
|
||||
result.transform(Snap.matrix()
|
||||
.translate(this.padding - box.x, this.padding - box.y));
|
||||
snap.attr({
|
||||
this.snap.attr({
|
||||
width: box.width + this.padding * 2,
|
||||
height: box.height + this.padding * 2
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user