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
af2be372
Commit
af2be372
authored
Mar 28, 2012
by
Aaron Leung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Correctly handling default arguments for mixins.
parent
23bc4ff1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
6 deletions
+23
-6
document_eval_pending.cpp
document_eval_pending.cpp
+18
-5
input.scss
spec/basic/17_basic_mixins/input.scss
+2
-0
output.css
spec/basic/17_basic_mixins/output.css
+3
-1
No files found.
document_eval_pending.cpp
View file @
af2be372
...
...
@@ -2,7 +2,6 @@
#include "evaluator.hpp"
namespace
Sass
{
void
Document
::
eval_pending
()
{
for
(
int
i
=
0
;
i
<
context
.
pending
.
size
();
++
i
)
{
...
...
@@ -50,20 +49,33 @@ namespace Sass {
n
.
children
->
pop_back
();
Environment
m_env
;
// bind arguments
for
(
int
i
=
0
,
j
=
0
;
i
<
args
.
size
();
++
i
)
{
if
(
args
[
i
].
type
==
Node
::
assignment
)
{
Node
arg
(
args
[
i
]);
Token
key
(
arg
[
0
].
token
);
if
(
!
m_env
.
query
(
key
))
{
m_env
[
key
]
=
eval
(
arg
[
1
],
context
.
global_env
);
Token
name
(
arg
[
0
].
token
);
if
(
!
m_env
.
query
(
name
))
{
m_env
[
name
]
=
eval
(
arg
[
1
],
context
.
global_env
);
}
}
else
{
// TO DO: ensure (j < params.size())
m_env
[
params
[
j
].
token
]
=
eval
(
args
[
i
],
context
.
global_env
);
Node
param
(
params
[
j
]);
Token
name
(
param
.
type
==
Node
::
variable
?
param
.
token
:
param
[
0
].
token
);
m_env
[
name
]
=
eval
(
args
[
i
],
context
.
global_env
);
++
j
;
}
}
// plug the holes with default arguments if any
for
(
int
i
=
0
;
i
<
params
.
size
();
++
i
)
{
if
(
params
[
i
].
type
==
Node
::
assignment
)
{
Node
param
(
params
[
i
]);
Token
name
(
param
[
0
].
token
);
if
(
!
m_env
.
query
(
name
))
{
m_env
[
name
]
=
eval
(
param
[
1
],
context
.
global_env
);
}
}
}
m_env
.
link
(
context
.
global_env
);
for
(
int
i
=
0
;
i
<
body
.
size
();
++
i
)
{
...
...
@@ -71,6 +83,7 @@ namespace Sass {
}
n
+=
body
;
// ideally say: n += apply(mixin, args, context.global_env);
}
break
;
}
}
...
...
spec/basic/17_basic_mixins/input.scss
View file @
af2be372
...
...
@@ -17,6 +17,8 @@ a {
@include
foo
(
$y
:
kwd-y
,
$x
:
kwd-x
);
goo
:
boo
hoo
;
@include
hux
;
@include
bar
(
pug
);
@include
bar
(
pug
,
mug
);
}
...
...
spec/basic/17_basic_mixins/output.css
View file @
af2be372
...
...
@@ -4,7 +4,9 @@ a {
hugabug
:
why
eks
;
hugabug
:
kwd-y
kwd-x
;
goo
:
boo
hoo
;
no
:
parameters
here
;
}
no
:
parameters
here
;
flugablug
:
pug
flug
glug
;
flugablug
:
pug
mug
glug
;
}
div
{
blah
:
blah
from
a
variable
blah
;
}
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