Permalink
Browse files

Changed arguments-modifying functions, fixed the case with `border-im…

…age` with `fill`
  • Loading branch information...
1 parent 760f9f8 commit 9c05f9a4bb42cdf2205895922069fbc3bf7c3442 @kizu kizu committed with slang800 Sep 13, 2012
Showing with 34 additions and 8 deletions.
  1. +16 −8 lib/nib/vendor.styl
  2. +6 −0 test/cases/linear-gradient.css
  3. +3 −0 test/cases/linear-gradient.styl
  4. +6 −0 test/cases/vendor.css
  5. +3 −0 test/cases/vendor.styl
View
@@ -45,30 +45,36 @@ literal-join(string, literals)
return result
/*
- * Prepend matched argument with given prefix
+ * Modify matched arguments
* set strict to false to check as “begin with”
*/
-prepend-args(args, prefix, argument, strict = true)
+modify-args(args, argument, prefix = '', postfix = '', replace = false, strict = true)
result = ()
+ prefix = unquote(prefix)
+ postfix = unquote(postfix)
+
// Checking if there are values divided by comma
if is-comma-list(args)
for subargs in args
subresult = ()
for arg in subargs
if (arg == argument and strict) or (match('^'+s('%s',argument),''+arg) and !strict)
- arg = s('%s%s',unquote(prefix),arg)
- push(subresult, arg)
+ arg = s('%s%s%s', prefix, replace ? replace : arg, postfix)
+ push(subresult, arg) if arg != unquote('')
subresult = literal-join(' ', subresult) if length(subresult) > 1
push(result, subresult)
result = literal-join(', ', result)
else
for arg in args
if (arg == argument and strict) or (match('^'+s('%s',argument),''+arg) and !strict)
- arg = s('%s%s',unquote(prefix),arg)
- push(result, arg)
+ arg = s('%s%s%s', prefix, replace ? replace : arg, postfix)
+ push(result, arg) if arg != unquote('')
return result
+remove-args(args, argument, strict = true)
+ return modify-args(args, argument, replace: unquote(''), strict: strict)
+
/*
* Vendor support for the given prop / arguments,
* optionally specifying the only prefixes to utilize,
@@ -84,9 +90,11 @@ vendor(prop, args, only = null, ignore = null, vendor-property = true)
newargs = args
// Adjusting the args if needed
if prop in ('transition' 'transition-property')
- newargs = prepend-args(args, '-' + prefix + '-', transform)
+ newargs = modify-args(newargs, transform, '-' + prefix + '-')
if prop in ('border-image' 'background' 'background-image' 'cursor' 'list-style' 'list-style-image')
- newargs = prepend-args(args, '-' + prefix + '-', linear-gradient, false)
+ newargs = modify-args(newargs, linear-gradient, '-' + prefix + '-', strict: false)
+ if prop in ('border-image' 'border-image-slice')
+ newargs = remove-args(newargs, fill)
newprop = prop
newprop = '-' + prefix + '-' + prop if vendor-property
// TODO: make the adjustments for differences
@@ -54,6 +54,12 @@ body {
border-image: linear-gradient(top, #fff 0, #000 100%) 20% stretch stretch;
}
body {
+ -webkit-border-image: -webkit-linear-gradient(top, #fff 0, #000 100%) 20% stretch stretch;
+ -moz-border-image: -moz-linear-gradient(top, #fff 0, #000 100%) 20% stretch stretch;
+ -o-border-image: -o-linear-gradient(top, #fff 0, #000 100%) 20% stretch stretch;
+ border-image: linear-gradient(top, #fff 0, #000 100%) 20% fill stretch stretch;
+}
+body {
cursor: -webkit-linear-gradient(40deg, #f00 0, #0f0 100%);
cursor: -moz-linear-gradient(40deg, #f00 0, #0f0 100%);
cursor: -ms-linear-gradient(40deg, #f00 0, #0f0 100%);
@@ -28,6 +28,9 @@ body
body
border-image: linear-gradient(top, #fff, #000) 20% stretch stretch;
+body
+ border-image: linear-gradient(top, #fff, #000) 20% fill stretch stretch;
+
gradient-var = linear-gradient(40deg, red, lime)
body
View
@@ -150,6 +150,12 @@ section {
-moz-border-image: url("image.png") 20% stretch stretch;
border-image: url("image.png") 20% stretch stretch;
}
+section {
+ -o-border-image: url("image.png") 20% stretch stretch;
+ -webkit-border-image: url("image.png") 20% stretch stretch;
+ -moz-border-image: url("image.png") 20% stretch stretch;
+ border-image: url("image.png") 20% fill stretch stretch;
+}
p {
-webkit-hyphens: auto;
-moz-hyphens: auto;
View
@@ -79,6 +79,9 @@ button
section
border-image: url("image.png") 20% stretch stretch;
+section
+ border-image: url("image.png") 20% fill stretch stretch;
+
p
hyphens: auto

0 comments on commit 9c05f9a

Please sign in to comment.