demos/Collage/fabric.js
function setStyle(element, styles) {
    var elementStyle = element.style, match;
    if (!elementStyle) {
      return element;
    }
    if (typeof styles === 'string') {
      element.style.cssText += ';' + styles;
      return styles.indexOf('opacity') > -1
        ? setOpacity(element, styles.match(/opacity:\s*(\d?\.?\d*)/)[1])
        : element;
    }
    for (var property in styles) {
      if (property === 'opacity') {
        setOpacity(element, styles[property]);
      }
      else {
        var normalizedProperty = (property === 'float' || property === 'cssFloat')
          ? (typeof elementStyle.styleFloat === 'undefined' ? 'cssFloat' : 'styleFloat')
          : property;
        elementStyle[normalizedProperty] = styles[property];
      }
    }
    return element;
  }
function setStyle(element, styles) {
    var elementStyle = element.style, match;
    if (!elementStyle) {
      return element;
    }
    if (typeof styles === 'string') {
      element.style.cssText += ';' + styles;
      return styles.indexOf('opacity') > -1
        ? setOpacity(element, styles.match(/opacity:\s*(\d?\.?\d*)/)[1])
        : element;
    }
    for (var property in styles) {
      if (property === 'opacity') {
        setOpacity(element, styles[property]);
      }
      else {
        var normalizedProperty = (property === 'float' || property === 'cssFloat')
          ? (typeof elementStyle.styleFloat === 'undefined' ? 'cssFloat' : 'styleFloat')
          : property;
        elementStyle[normalizedProperty] = styles[property];
      }
    }
    return element;
  }
function setStyle ( element , styles ) { var elementStyle = element . style , match ; if ( ! elementStyle ) { return element ; } if ( typeof styles === 'string' ) { element . style . cssText += ';' + styles ; return styles . indexOf ( 'opacity' ) > - 1 ? setOpacity ( element , styles . match ( / opacity:\s*(\d?\.?\d*) / ) [ 1 ] ) : element ; } for ( var property in styles ) { if ( property === 'opacity' ) { setOpacity ( element , styles [ property ] ) ; } else { var normalizedProperty = ( property === 'float' || property === 'cssFloat' ) ? ( typeof elementStyle . styleFloat === 'undefined' ? 'cssFloat' : 'styleFloat' ) : property ; elementStyle [ normalizedProperty ] = styles [ property ] ; } } return element ; }
Cross-browser wrapper for setting element's style
@method setStyle
@memberOf fabric.util
@param {HTMLElement} element
@param {Object} styles
@return {HTMLElement} Element that was passed as a first argument
Cross - browser wrapper for setting element s style