开发者

jQuery expando properties

开发者 https://www.devze.com 2023-03-31 10:28 出处:网络
I have a question on jQuery expando properties. Basically I would like to understand in VERY simple terms:

I have a question on jQuery expando properties. Basically I would like to understand in VERY simple terms:

  1. How this whole process works like how jQuery adds the expando property,
  2. what is the criteria to add it to any element
  3. What is the exact reason which makes jQuery lightweight
  4. 开发者_JAVA技巧
  5. What exactly does the jQuery cache have?


Question 3 seems out of place but for the rest:

  • jQuery.expando is a string which is basically 'jQuery' + uniqueid (just a unique value)

Prior to version 1.4.4, the uniqueid is current timestamp.

After that from version 1.5.1, the uniqueid is version+Math.random() with dots replaced. To be clear, "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ).

  • jQuery.cache is an object that will store the data values

  • Element[ jQuery.expando ] is a int value/key that is where the object is stored in jQuery.cache

  • jQuery.cache[ Element[ jQuery.expando ] ] is an object of that elements data props

Take a look at this to see what I mean

0

精彩评论

暂无评论...
验证码 换一张
取 消