Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
node-sass
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
楚学文
node-sass
Commits
2d15ad0c
Commit
2d15ad0c
authored
Apr 16, 2012
by
Aaron Leung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Type checking for the numeric functions.
parent
445fe21d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
4 deletions
+20
-4
exceptional.scss
exceptional.scss
+3
-0
functions.cpp
functions.cpp
+17
-4
No files found.
exceptional.scss
View file @
2d15ad0c
...
@@ -43,4 +43,6 @@ div {
...
@@ -43,4 +43,6 @@ div {
flah
:
unquote
(
"hello"
);
flah
:
unquote
(
"hello"
);
grah
:
quote
(
hello
);
grah
:
quote
(
hello
);
hrah
:
quote
(
mukluk
);
hrah
:
quote
(
mukluk
);
mwah
:
percentage
(
.3
);
a
:
floor
(
10
.8%
);
}
}
\ No newline at end of file
functions.cpp
View file @
2d15ad0c
...
@@ -274,6 +274,7 @@ namespace Sass {
...
@@ -274,6 +274,7 @@ namespace Sass {
Node
percentage
(
const
vector
<
Token
>&
parameters
,
map
<
Token
,
Node
>&
bindings
)
{
Node
percentage
(
const
vector
<
Token
>&
parameters
,
map
<
Token
,
Node
>&
bindings
)
{
Node
cpy
(
bindings
[
parameters
[
0
]].
clone
());
Node
cpy
(
bindings
[
parameters
[
0
]].
clone
());
// TO DO: make sure it's not already a percentage
// TO DO: make sure it's not already a percentage
if
(
cpy
.
type
!=
Node
::
number
)
eval_error
(
"argument to percentage must be a unitless number"
,
cpy
.
line_number
,
cpy
.
file_name
);
cpy
.
content
.
numeric_value
=
cpy
.
content
.
numeric_value
*
100
;
cpy
.
content
.
numeric_value
=
cpy
.
content
.
numeric_value
*
100
;
cpy
.
type
=
Node
::
numeric_percentage
;
cpy
.
type
=
Node
::
numeric_percentage
;
return
cpy
;
return
cpy
;
...
@@ -286,9 +287,12 @@ namespace Sass {
...
@@ -286,9 +287,12 @@ namespace Sass {
if
(
cpy
.
type
==
Node
::
numeric_dimension
)
{
if
(
cpy
.
type
==
Node
::
numeric_dimension
)
{
cpy
.
content
.
dimension
.
numeric_value
=
std
::
floor
(
cpy
.
content
.
dimension
.
numeric_value
+
0.5
);
cpy
.
content
.
dimension
.
numeric_value
=
std
::
floor
(
cpy
.
content
.
dimension
.
numeric_value
+
0.5
);
}
}
else
{
else
if
(
cpy
.
type
==
Node
::
number
||
cpy
.
type
==
Node
::
numeric_percentage
)
{
cpy
.
content
.
numeric_value
=
std
::
floor
(
cpy
.
content
.
numeric_value
+
0.5
);
cpy
.
content
.
numeric_value
=
std
::
floor
(
cpy
.
content
.
numeric_value
+
0.5
);
}
}
else
{
eval_error
(
"argument to round must be numeric"
,
cpy
.
line_number
,
cpy
.
file_name
);
}
return
cpy
;
return
cpy
;
}
}
...
@@ -299,9 +303,12 @@ namespace Sass {
...
@@ -299,9 +303,12 @@ namespace Sass {
if
(
cpy
.
type
==
Node
::
numeric_dimension
)
{
if
(
cpy
.
type
==
Node
::
numeric_dimension
)
{
cpy
.
content
.
dimension
.
numeric_value
=
std
::
ceil
(
cpy
.
content
.
dimension
.
numeric_value
);
cpy
.
content
.
dimension
.
numeric_value
=
std
::
ceil
(
cpy
.
content
.
dimension
.
numeric_value
);
}
}
else
{
else
if
(
cpy
.
type
==
Node
::
number
||
cpy
.
type
==
Node
::
numeric_percentage
)
{
cpy
.
content
.
numeric_value
=
std
::
ceil
(
cpy
.
content
.
numeric_value
);
cpy
.
content
.
numeric_value
=
std
::
ceil
(
cpy
.
content
.
numeric_value
);
}
}
else
{
eval_error
(
"argument to ceil must be numeric"
,
cpy
.
line_number
,
cpy
.
file_name
);
}
return
cpy
;
return
cpy
;
}
}
...
@@ -312,9 +319,12 @@ namespace Sass {
...
@@ -312,9 +319,12 @@ namespace Sass {
if
(
cpy
.
type
==
Node
::
numeric_dimension
)
{
if
(
cpy
.
type
==
Node
::
numeric_dimension
)
{
cpy
.
content
.
dimension
.
numeric_value
=
std
::
floor
(
cpy
.
content
.
dimension
.
numeric_value
);
cpy
.
content
.
dimension
.
numeric_value
=
std
::
floor
(
cpy
.
content
.
dimension
.
numeric_value
);
}
}
else
{
else
if
(
cpy
.
type
==
Node
::
number
||
cpy
.
type
==
Node
::
numeric_percentage
)
{
cpy
.
content
.
numeric_value
=
std
::
floor
(
cpy
.
content
.
numeric_value
);
cpy
.
content
.
numeric_value
=
std
::
floor
(
cpy
.
content
.
numeric_value
);
}
}
else
{
eval_error
(
"argument to floor must be numeric"
,
cpy
.
line_number
,
cpy
.
file_name
);
}
return
cpy
;
return
cpy
;
}
}
...
@@ -325,8 +335,11 @@ namespace Sass {
...
@@ -325,8 +335,11 @@ namespace Sass {
if
(
cpy
.
type
==
Node
::
numeric_dimension
)
{
if
(
cpy
.
type
==
Node
::
numeric_dimension
)
{
cpy
.
content
.
dimension
.
numeric_value
=
std
::
fabs
(
cpy
.
content
.
dimension
.
numeric_value
);
cpy
.
content
.
dimension
.
numeric_value
=
std
::
fabs
(
cpy
.
content
.
dimension
.
numeric_value
);
}
}
else
if
(
cpy
.
type
==
Node
::
number
||
cpy
.
type
==
Node
::
numeric_percentage
){
cpy
.
content
.
numeric_value
=
std
::
abs
(
cpy
.
content
.
numeric_value
);
}
else
{
else
{
cpy
.
content
.
numeric_value
=
std
::
fabs
(
cpy
.
content
.
numeric_valu
e
);
eval_error
(
"argument to abs must be numeric"
,
cpy
.
line_number
,
cpy
.
file_nam
e
);
}
}
return
cpy
;
return
cpy
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment