Skip to content

Commit 38f23be

Browse files
committed
0.21.1
1 parent 75a86c4 commit 38f23be

File tree

4 files changed

+41
-17
lines changed

4 files changed

+41
-17
lines changed

CHANGELOG.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
## 0.21.1
2+
3+
### Enhancement
4+
5+
* Add support for more Math notations:
6+
`&&`, `||`, `|`, `&`, ``, ``
7+
8+
### Fixes
9+
10+
* Fix default context value.
11+
12+
<br /> <br />
13+
14+
15+
116
## 0.21.0
217

318
### Features
@@ -16,7 +31,7 @@
1631
}
1732
```
1833

19-
### changes
34+
### Changes
2035

2136
* Use a shorter name `fill` for `fill-rule`.
2237

css-doodle.js

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! css-doodle@0.21.0 */
1+
/*! css-doodle@0.21.1 */
22
(function (global, factory) {
33
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
44
typeof define === 'function' && define.amd ? define(factory) :
@@ -1489,15 +1489,18 @@
14891489
}
14901490

14911491
const operator = {
1492-
'^': 5,
1493-
'*': 4, '/': 4, '%': 4,
1494-
'+': 3, '-': 3,
1495-
'(': 2, ')': 2,
1496-
'<': 1, '>': 1,
1497-
'=': 1, '==': 1,
1498-
'≤': 1, '<=': 1,
1499-
'≥': 1, '>=': 1,
1500-
'≠': 1, '!=': 1,
1492+
'^': 7,
1493+
'*': 6, '/': 6, '÷': 6, '%': 6,
1494+
'&': 5, '|': 5,
1495+
'+': 4, '-': 4,
1496+
'<': 3, '>': 3,
1497+
'=': 3, '==': 3,
1498+
'≤': 3, '<=': 3,
1499+
'≥': 3, '>=': 3,
1500+
'≠': 3, '!=': 3,
1501+
'∧': 2, '&&': 2,
1502+
'∨': 2, '||': 2,
1503+
'(': 1 , ')': 1,
15011504
};
15021505

15031506
function calc$1(expr, context, repeat = []) {
@@ -1576,6 +1579,9 @@
15761579
if (c == '=' && last_token && /^[!<>=]$/.test(last_token.value)) {
15771580
last_token.value += c;
15781581
}
1582+
else if (/^[|&]$/.test(c) && last_token && last_token.value == c) {
1583+
last_token.value += c;
1584+
}
15791585
else if (c == '-' && expr[i - 1] == 'e') {
15801586
num += c;
15811587
}
@@ -1705,15 +1711,18 @@
17051711
case '+': return a + b;
17061712
case '-': return a - b;
17071713
case '*': return a * b;
1708-
case '/': return a / b;
17091714
case '%': return a % b;
1710-
case '^': return Math.pow(a, b);
1715+
case '|': return a | b;
17111716
case '<': return a < b;
17121717
case '>': return a > b;
1718+
case '^': return Math.pow(a, b);
1719+
case '÷': case '/': return a / b;
17131720
case '=': case '==': return a == b;
17141721
case '≤': case '<=': return a <= b;
17151722
case '≥': case '>=': return a >= b;
17161723
case '≠': case '!=': return a != b;
1724+
case '∧': case '&&': return a && b;
1725+
case '∨': case '||': return a || b;
17171726
}
17181727
}
17191728

@@ -3191,9 +3200,9 @@
31913200

31923201
match({ count, grid, x, y }) {
31933202
return expr => {
3194-
return !!calc(expr, {
3203+
return !!calc('(' + expr + ')', {
31953204
x, y,
3196-
X: grid.x, Y: grid.Y,
3205+
X: grid.x, Y: grid.y,
31973206
i: count,
31983207
});
31993208
}

css-doodle.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "css-doodle",
3-
"version": "0.21.0",
3+
"version": "0.21.1",
44
"description": "A web component for drawing patterns with CSS",
55
"main": "css-doodle.js",
66
"scripts": {

0 commit comments

Comments
 (0)