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
c87719a9
Commit
c87719a9
authored
Sep 06, 2012
by
Aaron Leung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding error checking to change-color.
parent
10044861
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
0 deletions
+12
-0
functions.cpp
functions.cpp
+12
-0
No files found.
functions.cpp
View file @
c87719a9
...
...
@@ -374,10 +374,17 @@ namespace Sass {
bool
no_rgb
=
r
.
is_false
()
&&
g
.
is_false
()
&&
b
.
is_false
();
bool
no_hsl
=
h
.
is_false
()
&&
s
.
is_false
()
&&
l
.
is_false
();
if
(
color
.
type
()
!=
Node
::
numeric_color
)
{
throw_eval_error
(
"first argument to 'change-color' must be a color"
,
color
.
path
(),
color
.
line
());
}
if
(
!
no_rgb
&&
!
no_hsl
)
{
throw_eval_error
(
"cannot specify RGB and HSL values for a color at the same time for 'change-color'"
,
r
.
path
(),
r
.
line
());
}
else
if
(
!
no_rgb
)
{
if
(
!
r
.
is_false
()
&&
!
r
.
is_numeric
())
throw_eval_error
(
"argument $red of 'change-color' must be numeric"
,
r
.
path
(),
r
.
line
());
if
(
!
g
.
is_false
()
&&
!
g
.
is_numeric
())
throw_eval_error
(
"argument $green of 'change-color' must be numeric"
,
g
.
path
(),
g
.
line
());
if
(
!
b
.
is_false
()
&&
!
b
.
is_numeric
())
throw_eval_error
(
"argument $blue of 'change-color' must be numeric"
,
b
.
path
(),
b
.
line
());
if
(
!
a
.
is_false
()
&&
!
a
.
is_numeric
())
throw_eval_error
(
"argument $alpha of 'change-color' must be numeric"
,
a
.
path
(),
a
.
line
());
double
new_r
=
(
r
.
is_false
()
?
color
[
0
]
:
r
).
numeric_value
();
double
new_g
=
(
g
.
is_false
()
?
color
[
1
]
:
g
).
numeric_value
();
double
new_b
=
(
b
.
is_false
()
?
color
[
2
]
:
b
).
numeric_value
();
...
...
@@ -389,6 +396,10 @@ namespace Sass {
color
[
1
].
numeric_value
(),
color
[
2
].
numeric_value
(),
new_Node
));
if
(
!
h
.
is_false
()
&&
!
h
.
is_numeric
())
throw_eval_error
(
"argument $hue of 'change-color' must be numeric"
,
h
.
path
(),
h
.
line
());
if
(
!
s
.
is_false
()
&&
!
s
.
is_numeric
())
throw_eval_error
(
"argument $saturation of 'change-color' must be numeric"
,
s
.
path
(),
s
.
line
());
if
(
!
l
.
is_false
()
&&
!
l
.
is_numeric
())
throw_eval_error
(
"argument $lightness of 'change-color' must be numeric"
,
l
.
path
(),
l
.
line
());
if
(
!
a
.
is_false
()
&&
!
a
.
is_numeric
())
throw_eval_error
(
"argument $alpha of 'change-color' must be numeric"
,
a
.
path
(),
a
.
line
());
double
new_h
=
(
h
.
is_false
()
?
hsl_node
[
0
].
numeric_value
()
:
h
.
numeric_value
());
double
new_s
=
(
s
.
is_false
()
?
hsl_node
[
1
].
numeric_value
()
:
s
.
numeric_value
());
double
new_l
=
(
l
.
is_false
()
?
hsl_node
[
2
].
numeric_value
()
:
l
.
numeric_value
());
...
...
@@ -396,6 +407,7 @@ namespace Sass {
return
hsla_impl
(
new_h
,
new_s
,
new_l
,
new_a
,
new_Node
);
}
else
if
(
!
a
.
is_false
())
{
if
(
!
a
.
is_numeric
())
throw_eval_error
(
"argument $alpha of 'change-color' must be numeric"
,
a
.
path
(),
a
.
line
());
return
new_Node
(
""
,
0
,
color
[
0
].
numeric_value
(),
color
[
1
].
numeric_value
(),
...
...
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