Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It is possible, but its use in production <strong>should be avoided at all costs</strong>.</p> <p>Changing the core functionality of a library that is so often used in tandem with multiple plugins is a bad, dangerous, and bad-and-dangerous idea.</p> <p>It may be possible for you to cause the overwritten method to interface and behave in its original way and to only behave differently for a subset of parameters; however, in subsequent releases of the library, if this core method changes, you may, in short, be screwed and have to revisit the overwritten method.</p> <p>It's best to use a different method name. Perhaps, for your uses, you can use <code>style</code> , <code>xCss</code>, <code>cssExt</code>, or something along those lines.</p> <p>If you're looking for one method to combine the functionality of both your method and the core method, then it is best to take the opposite approach. Instead of overwriting the core method, wrap it with additional functionality, and of course, a new name.</p> <pre><code>jQuery.fn.xCss = (function() { var compoundProperties = { 'padding': ['padding-top', 'padding-right' ...], 'border': ['border-width', 'border-style', ...], 'background': ['background-color', ...], ... }; return function(property, value) { // Use plugin functionality if ( compoundProperties.hasOwnPropery(property) ) { // Get value if ( !value ) { var propertySet = compoundProperties[property], result = []; for ( var i=0, l=propertySet.length; i&lt;l; ++i ) { result.push( this.css(propertySet[i]) ); } return result.join(" "); } // Set value ... return this; } // Use core functionality return this.css.apply(this, arguments); }; })(); </code></pre> <p>* Code not tested or complete.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload