angular 源码中似乎有重复的代码?

2015-11-18 14:59:13 +08:00
 alsodium
```js
var lowercase = function (string) {
return isString (string) ? string.toLowerCase () : string;
};

var manualLowercase = function (s) {
return isString (s) ? s.replace (/[A-Z]/g, function (ch) {
return String.fromCharCode (ch.charCodeAt (0) | 32);
}) : s;
};
```

这两个函数作用是相同的吧,可是为什么要写两个呢?反正都是将大写变小写
1654 次点击
所在节点    问与答
3 条回复
doublleft
2015-11-18 15:16:35 +08:00
涨姿势
p2p
2015-11-18 15:36:00 +08:00
// String#toLowerCase and String#toUpperCase don't produce correct results in browsers with Turkish
// locale, for this reason we need to detect this case and redefine lowercase/uppercase methods
// with correct but slower alternatives.

if ('i' !== 'I'.toLowerCase()) {
lowercase = manualLowercase;
uppercase = manualUppercase;
}
rannnn
2015-11-18 15:59:08 +08:00
土耳其语的 i 大写是不是 I
比如'input'.toUpperCase() !== 'INPUT'

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/237062

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX