Sha256: aa9c92360c6a56d8d41212b96191fafab6d7794fd68ec2fb6b46ee08c20daa24

Contents?: true

Size: 1.23 KB

Versions: 7

Compression:

Stored size: 1.23 KB

Contents

var prefixes = ['-webkit-', '-moz-', '-ms-']

/**
 *  Binding for CSS styles
 */
module.exports = {

    bind: function () {
        var prop = this.arg
        if (!prop) return
        if (prop.charAt(0) === '$') {
            // properties that start with $ will be auto-prefixed
            prop = prop.slice(1)
            this.prefixed = true
        }
        this.prop = prop
    },

    update: function (value) {
        var prop = this.prop,
            isImportant
        /* jshint eqeqeq: true */
        // cast possible numbers/booleans into strings
        if (value != null) value += ''
        if (prop) {
            if (value) {
                isImportant = value.slice(-10) === '!important'
                    ? 'important'
                    : ''
                if (isImportant) {
                    value = value.slice(0, -10).trim()
                }
            }
            this.el.style.setProperty(prop, value, isImportant)
            if (this.prefixed) {
                var i = prefixes.length
                while (i--) {
                    this.el.style.setProperty(prefixes[i] + prop, value, isImportant)
                }
            }
        } else {
            this.el.style.cssText = value
        }
    }

}

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
fluentd-ui-0.3.8 vendor/assets/javascripts/bower/vue/src/directives/style.js
fluentd-ui-0.3.7 vendor/assets/javascripts/bower/vue/src/directives/style.js
fluentd-ui-0.3.6 vendor/assets/javascripts/bower/vue/src/directives/style.js
fluentd-ui-0.3.5 vendor/assets/javascripts/bower/vue/src/directives/style.js
fluentd-ui-0.3.3 vendor/assets/javascripts/bower/vue/src/directives/style.js
fluentd-ui-0.3.2 vendor/assets/javascripts/bower/vue/src/directives/style.js
fluentd-ui-0.3.1 vendor/assets/javascripts/bower/vue/src/directives/style.js