Skip to content

Commit

Permalink
CSS fixes
Browse files Browse the repository at this point in the history
Fix for CSS settings like `$(el).css(opacity,0);` where the false-y
values would not be set.

Also fixed and exposed`$.prefixedProp` and `$.camelCase` utilities to
allow for eventual animation support.
  • Loading branch information
shshaw committed May 20, 2016
1 parent 304f80b commit 6a885b0
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 22 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "cash",
"main": "dist/cash.js",
"version": "1.3.2",
"version": "1.3.3",
"homepage": "https://github.com/kenwheeler/cash",
"authors": [
"Ken Wheeler <[email protected]>"
Expand Down
20 changes: 13 additions & 7 deletions dist/cash.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use strict";

/*! cash-dom 1.3.2, https://github.com/kenwheeler/cash @license MIT */
/*! cash-dom 1.3.3, https://github.com/kenwheeler/cash @license MIT */
(function (root, factory) {
if (typeof define === "function" && define.amd) {
define(factory);
Expand Down Expand Up @@ -401,14 +401,17 @@

});

var getPrefixedProp = (function () {
var cache = {}, div = doc.createElement("div"), style = div.style, camelRegex = /(?:^\w|[A-Z]|\b\w)/g, whiteSpace = /[\s-]+/g;

function camelCase(str) {
var camelCase = (function () {
var camelRegex = /(?:^\w|[A-Z]|\b\w)/g, whiteSpace = /[\s-_]+/g;
return function (str) {
return str.replace(camelRegex, function (letter, index) {
return letter[index === 0 ? "toLowerCase" : "toUpperCase"]();
}).replace(whiteSpace, "");
}
};
}());

var getPrefixedProp = (function () {
var cache = {}, doc = document, div = doc.createElement("div"), style = div.style;

return function (prop) {
prop = camelCase(prop);
Expand All @@ -429,11 +432,14 @@
};
}());

cash.prefixedProp = getPrefixedProp;
cash.camelCase = camelCase;

fn.extend({
css: function (prop, value) {
if (isString(prop)) {
prop = getPrefixedProp(prop);
return (value ? this.each(function (v) {
return (arguments.length > 1 ? this.each(function (v) {
return v.style[prop] = value;
}) : win.getComputedStyle(this[0])[prop]);
}
Expand Down
Loading

0 comments on commit 6a885b0

Please sign in to comment.