[英]Why does Google Code Prettifier stop working when I use JQuery DatePicker (or vice versa)
If the Google Code Prettifier (or JQuery Syntax Highlighter ) is being used in the same page as the JQuery DatePicker , neither will work properly. 如果在与JQuery DatePicker相同的页面中使用了Google Code Prettifier (或JQuery语法荧光笔 ),则两者均无法正常工作。 Why is this?
为什么是这样?
Because they both monkey patch a now method onto the native Date object! 因为他们俩都在本地Date对象上添加了now方法!
Prettify does this: 美化做到这一点:
var clock = Date;
if (!clock['now']) {
clock = { 'now': function () { return +(new Date); } };
}
DatePicker does this: DatePicker这样做:
Date.now=function(){return new Date();}
So Prettify's returns an int representation of the Date (so that it can add on some ms) while DatePicker returns a Date. 因此,Prettify的返回Date的int表示形式(以便可以在某些ms上添加),而DatePicker返回一个Date。
(IMO this kind of thing is outrageous in two such commonly-used libraries.) (在两个这样的常用库中,IMO这类事情太过残酷了。)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.