برخی از قابلیت های جدید جیکوئری

16 views
Skip to first unread message

AlirezaWeb

unread,
Nov 11, 2013, 2:53:47 PM11/11/13
to alire...@googlegroups.com

نکته های بسیار جالبی تو این مطلب هست، حتما بخوانید: 

7 years ago …

... XMLHttpRequest object would work in IE7+ ...

...

شبیه سازی سلکتور jQuery در IE8 به بالا براحتی و در یه خط !
واضافه کردن متد On جیکونری اونم در یه خط !
و یه خط ساده هم برای استفاده کردن !

var $ = document.querySelectorAll.bind(document);
Element.prototype.on = Element.prototype.addEventListener;

$('#somelink')[0].on('touchstart', handleTouch);

Beautifully simple.

I’ve taken this idea a little further and used it on a few specific projects, adding support for chaining, looping and simplifying the syntax. Comes in at <200 bytes gzipped. But the point is that today we have features natively available, and I’m trying to consider my audience before dropping in jQuery by default.



The BBC use the following test for cutting the mustard:

if ('querySelector' in document && 
   
'localStorage' in window &&
   
'addEventListener' in window) {
   
// bootstrap the JavaScript application
}

I know off the top of my head IE8 doesn’t support addEventListener (but there is a polyfill)

jquery:
$('body').addClass('hasJS');

or
pure javascript:
document.body.className = 'hasJS';

If the body might have a class already, just append (jQuery has to read the className property too):

document.body.className += ' hasJS'.


اینم نگاه کنید!

https://github.com/inexorabletash/polyfill


https://gist.github.com/connrs/2724353

برای مثال یک پیاده سازی addClass جیکوئری:


Element.prototype.addClass = function(cls){
    this.className += ' '+cls;
}


 راه حل اساسی

querySelectorAll polyfill :

https://gist.github.com/MoOx/5235317


پرفرمنس
این یه نمونه رو ببینید
یعنی ie6 هم همینور ساپورت میکنه و نیازی به جیکوئری نداره ...



تستهای دیگه


---
www.alirezaweb.com
شما به این دلیل این پیام را دریافت کرده‌اید که در گروه Google Groups "AlirezaWeb" مشترک شده‌اید.
جهت لغو اشتراک از این گروه، ایمیلی به alirezaweb+...@googlegroups.com ارسال کنید.
از این گروه در http://groups.google.com/group/alirezaweb?hl=fa دیدن کنید.
برای گزینه‌های بیشتر، از https://groups.google.com/groups/opt_out دیدن کنید.
Reply all
Reply to author
Forward
0 new messages