classnames-rails 1.0.0 → 2.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 38016af519add117dbcb0c83dd2d684add7bf72b
4
- data.tar.gz: 6dd2860a30275c4beb97fbb0cb1a4a9c4a8f4b5b
3
+ metadata.gz: cefc251dba55eb5f5a0d5ec3d57620e4302d21e2
4
+ data.tar.gz: a89b05960dfc18b4332d2793381046c1b831d434
5
5
  SHA512:
6
- metadata.gz: f272c029dc21a587f271f2b283c6db4393bbd3359f0617282bb5ee68d8af087888ea4a3aa195f71a5a57e23acf6df4c397392847160e48218b406c28b07352f0
7
- data.tar.gz: 68ff81d4c5cc2faf408fd9ab8f9aef350219d83edbc51299e102cc477861cf4a909f956bb94743625569298020f8828189d4611c87ad8e3568dc1144d3017efa
6
+ metadata.gz: 8ad3560265be9ba82ec1f56aa2bd8e6a8db5376701f7265f634661321339301daab695bbdfe111d72433030fde883f8dde971957f90f47ebd2a313061e1a345f
7
+ data.tar.gz: 55bd0eb155629d5a039e605c0a85ee82581de9ba3cda375c0473469f05dc20e5bb217f7cb310f31c1413112350b8a39184d29d45a9daf3e8487fb99069bea8a1
@@ -1,5 +1,5 @@
1
1
  module Classnames
2
2
  module Rails
3
- VERSION = "1.0.0"
3
+ VERSION = "2.1.5"
4
4
  end
5
5
  end
@@ -3,6 +3,7 @@
3
3
  Licensed under the MIT License (MIT), see
4
4
  http://jedwatson.github.io/classnames
5
5
  */
6
+ /* global define */
6
7
 
7
8
  (function () {
8
9
  'use strict';
@@ -16,16 +17,17 @@
16
17
  }
17
18
  }
18
19
 
20
+ var hasOwn = {}.hasOwnProperty;
21
+
19
22
  function _parseNumber (resultSet, num) {
20
23
  resultSet[num] = true;
21
24
  }
22
25
 
23
26
  function _parseObject (resultSet, object) {
24
27
  for (var k in object) {
25
- if (object.hasOwnProperty(k)) {
28
+ if (hasOwn.call(object, k)) {
26
29
  if (object[k]) {
27
30
  resultSet[k] = true;
28
-
29
31
  } else {
30
32
  delete resultSet[k];
31
33
  }
@@ -48,7 +50,7 @@
48
50
  var argType = typeof arg;
49
51
 
50
52
  // 'foo bar'
51
- if ('string' === argType) {
53
+ if (argType === 'string') {
52
54
  _parseString(resultSet, arg);
53
55
 
54
56
  // ['foo', 'bar', ...]
@@ -56,11 +58,11 @@
56
58
  _parseArray(resultSet, arg);
57
59
 
58
60
  // { 'foo': true, ... }
59
- } else if ('object' === argType) {
61
+ } else if (argType === 'object') {
60
62
  _parseObject(resultSet, arg);
61
63
 
62
64
  // '130'
63
- } else if ('number' === argType) {
65
+ } else if (argType === 'number') {
64
66
  _parseNumber(resultSet, arg);
65
67
  }
66
68
  }
@@ -68,28 +70,29 @@
68
70
  function _classNames () {
69
71
  var classSet = {};
70
72
  _parseArray(classSet, arguments);
71
-
72
- var classes = '';
73
+
74
+ var list = [];
75
+
73
76
  for (var k in classSet) {
74
- classes += ' ' + k;
77
+ if (hasOwn.call(classSet, k) && classSet[k]) {
78
+ list.push(k)
79
+ }
75
80
  }
76
81
 
77
- return classes.substr(1);
82
+ return list.join(' ');
78
83
  }
79
84
 
80
85
  return _classNames;
81
-
82
86
  })();
83
87
 
84
- if (typeof define === 'function' && typeof define.amd === 'object' && define.amd) {
85
- // AMD. Register as an anonymous module.
86
- define(function () {
88
+ if (typeof module !== 'undefined' && module.exports) {
89
+ module.exports = classNames;
90
+ } else if (typeof define === 'function' && typeof define.amd === 'object' && define.amd) {
91
+ // register as 'classnames', consistent with npm package name
92
+ define('classnames', function () {
87
93
  return classNames;
88
94
  });
89
- } else if (typeof module !== 'undefined' && module.exports) {
90
- module.exports = classNames;
91
95
  } else {
92
96
  window.classNames = classNames;
93
97
  }
94
-
95
98
  }());
@@ -3,12 +3,14 @@
3
3
  Licensed under the MIT License (MIT), see
4
4
  http://jedwatson.github.io/classnames
5
5
  */
6
+ /* global define */
6
7
 
7
8
  (function () {
8
9
  'use strict';
9
10
 
10
- function classNames () {
11
+ var hasOwn = {}.hasOwnProperty;
11
12
 
13
+ function classNames () {
12
14
  var classes = '';
13
15
 
14
16
  for (var i = 0; i < arguments.length; i++) {
@@ -17,15 +19,13 @@
17
19
 
18
20
  var argType = typeof arg;
19
21
 
20
- if ('string' === argType || 'number' === argType) {
22
+ if (argType === 'string' || argType === 'number') {
21
23
  classes += ' ' + arg;
22
-
23
24
  } else if (Array.isArray(arg)) {
24
25
  classes += ' ' + classNames.apply(null, arg);
25
-
26
- } else if ('object' === argType) {
26
+ } else if (argType === 'object') {
27
27
  for (var key in arg) {
28
- if (arg.hasOwnProperty(key) && arg[key]) {
28
+ if (hasOwn.call(arg, key) && arg[key]) {
29
29
  classes += ' ' + key;
30
30
  }
31
31
  }
@@ -35,15 +35,14 @@
35
35
  return classes.substr(1);
36
36
  }
37
37
 
38
- if (typeof define === 'function' && typeof define.amd === 'object' && define.amd) {
39
- // AMD. Register as an anonymous module.
40
- define(function () {
38
+ if (typeof module !== 'undefined' && module.exports) {
39
+ module.exports = classNames;
40
+ } else if (typeof define === 'function' && typeof define.amd === 'object' && define.amd) {
41
+ // register as 'classnames', consistent with npm package name
42
+ define('classnames', function () {
41
43
  return classNames;
42
44
  });
43
- } else if (typeof module !== 'undefined' && module.exports) {
44
- module.exports = classNames;
45
45
  } else {
46
46
  window.classNames = classNames;
47
47
  }
48
-
49
48
  }());
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: classnames-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - andyyou
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-05-29 00:00:00.000000000 Z
11
+ date: 2015-10-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -96,7 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
96
96
  version: '0'
97
97
  requirements: []
98
98
  rubyforge_project:
99
- rubygems_version: 2.4.5
99
+ rubygems_version: 2.4.5.1
100
100
  signing_key:
101
101
  specification_version: 4
102
102
  summary: Gem package from classnames of javascript