Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 826957a

Browse files
committedDec 5, 2014
refactor(*): DRY camelcase method
remove the camelCase function from jqLite and use the one from the public API
1 parent 5cf03e7 commit 826957a

File tree

4 files changed

+5
-42
lines changed

4 files changed

+5
-42
lines changed
 

‎src/jqLite.js

+1-14
Original file line numberDiff line numberDiff line change
@@ -127,19 +127,6 @@ var MOZ_HACK_REGEXP = /^moz([A-Z])/;
127127
var MOUSE_EVENT_MAP= { mouseleave: "mouseout", mouseenter: "mouseover"};
128128
var jqLiteMinErr = minErr('jqLite');
129129

130-
/**
131-
* Converts snake_case to camelCase.
132-
* Also there is special case for Moz prefix starting with upper case letter.
133-
* @param name Name to normalize
134-
*/
135-
function camelCase(name) {
136-
return name.
137-
replace(SPECIAL_CHARS_REGEXP, function(_, separator, letter, offset) {
138-
return offset ? letter.toUpperCase() : letter;
139-
}).
140-
replace(MOZ_HACK_REGEXP, 'Moz$1');
141-
}
142-
143130
var SINGLE_TAG_REGEXP = /^<(\w+)\s*\/?>(?:<\/\1>|)$/;
144131
var HTML_REGEXP = /<|&#?\w+;/;
145132
var TAG_NAME_REGEXP = /<([\w:]+)/;
@@ -577,7 +564,7 @@ forEach({
577564
hasClass: jqLiteHasClass,
578565

579566
css: function(element, name, value) {
580-
name = camelCase(name);
567+
name = camelcase(name);
581568

582569
if (isDefined(value)) {
583570
element.style[name] = value;

‎src/ng/compile.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2495,7 +2495,7 @@ var PREFIX_REGEXP = /^((?:x|data)[\:\-_])/i;
24952495
* @param name Name to normalize
24962496
*/
24972497
function directiveNormalize(name) {
2498-
return camelCase(name.replace(PREFIX_REGEXP, ''));
2498+
return camelcase(name.replace(PREFIX_REGEXP, ''));
24992499
}
25002500

25012501
/**

‎src/ng/sce.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1033,13 +1033,13 @@ function $SceProvider() {
10331033

10341034
forEach(SCE_CONTEXTS, function(enumValue, name) {
10351035
var lName = lowercase(name);
1036-
sce[camelCase("parse_as_" + lName)] = function(expr) {
1036+
sce[camelcase("parse_as_" + lName)] = function(expr) {
10371037
return parse(enumValue, expr);
10381038
};
1039-
sce[camelCase("get_trusted_" + lName)] = function(value) {
1039+
sce[camelcase("get_trusted_" + lName)] = function(value) {
10401040
return getTrusted(enumValue, value);
10411041
};
1042-
sce[camelCase("trust_as_" + lName)] = function(value) {
1042+
sce[camelcase("trust_as_" + lName)] = function(value) {
10431043
return trustAs(enumValue, value);
10441044
};
10451045
});

‎test/jqLiteSpec.js

-24
Original file line numberDiff line numberDiff line change
@@ -1965,30 +1965,6 @@ describe('jqLite', function() {
19651965
});
19661966
});
19671967

1968-
1969-
describe('camelCase', function() {
1970-
it('should leave non-dashed strings alone', function() {
1971-
expect(camelCase('foo')).toBe('foo');
1972-
expect(camelCase('')).toBe('');
1973-
expect(camelCase('fooBar')).toBe('fooBar');
1974-
});
1975-
1976-
1977-
it('should covert dash-separated strings to camelCase', function() {
1978-
expect(camelCase('foo-bar')).toBe('fooBar');
1979-
expect(camelCase('foo-bar-baz')).toBe('fooBarBaz');
1980-
expect(camelCase('foo:bar_baz')).toBe('fooBarBaz');
1981-
});
1982-
1983-
1984-
it('should covert browser specific css properties', function() {
1985-
expect(camelCase('-moz-foo-bar')).toBe('MozFooBar');
1986-
expect(camelCase('-webkit-foo-bar')).toBe('webkitFooBar');
1987-
expect(camelCase('-webkit-foo-bar')).toBe('webkitFooBar');
1988-
});
1989-
});
1990-
1991-
19921968
describe('jqLiteDocumentLoaded', function() {
19931969

19941970
function createMockWindow(readyState) {

0 commit comments

Comments
 (0)
This repository has been archived.