Code coverage report for lib/prototypes/dom.js

Statements: 58.54% (24 / 41)      Branches: 0% (0 / 6)      Functions: 45.45% (5 / 11)      Lines: 58.54% (24 / 41)      Ignored: none     

All files » lib/prototypes/ » dom.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213    1   1 1 1                                                                                                                                                 1         1   3 3                                         3                             3     1   10                                                     1   3       3 3 3                                           1   6                       1   1           1 1 1      
'use strict';
 
var _Object$keys = require('babel-runtime/core-js/object/keys')['default'];
 
var elements = require('../elements');
var Element = require('../element');
var ElementsArray = require('../elements_array');
 
/**
 * Prefer use of {@link ElementsArray#getAttribute} and {@link ElementsArray#setAttribute}
 * <pre><code>
 * .attr(values)
 * .attr(name, value)
 * </code></pre>
 
 * @name ElementsArray#attr
 * @method
 */
 
/**
 * Prefer use of {@link ElementsArray#getProperty} and {@link ElementsArray#setProperty}
 * <pre><code>
 * .prop(properties)
 * .prop(name, value)
 * </code></pre>
 *
 * @name ElementsArray#prop
 * @method
 */
 
/**
 * Prefer use of {@link ElementsArray#getStyle} and {@link ElementsArray#setStyle}
 * <pre><code>
 * .style(properties)
 * .style(name, value)
 * </code></pre>
 *
 * @name ElementsArray#style
 * @method
 */
 
/**
 * Prefer use of {@link Element#getAttribute} and {@link Element#setAttribute}
 * <pre><code>
 * .attr(values)
 * .attr(name, value)
 * .attr(name)
 * </code></pre>
 *
 * @name Element#attr
 * @method
 */
 
/**
 * Prefer use of {@link Element#getProperty} and {@link Element#setProperty}
 * <pre><code>
 * .prop(properties)
 * .prop(name, value)
 * .prop(name)
 * </code></pre>
 *
 * @name Element#prop
 * @method
 */
 
/**
 * Prefer use of {@link Element#getStyle} and {@link Element#setStyle}
 * <pre><code>
 * .style(properties)
 * .style(name, value)
 * .style(name)
 * </code></pre>
 *
 * @name Element#style
 * @method
 *
 *
 */
 
var _methodCalledToMethodSuffix = {
    attr: 'Attribute',
    prop: 'Property',
    style: 'Style'
};
'attr prop style'.split(' ').forEach( /** @function 
                                      * @param mName */function (mName) {
    var mEltSuffix = _methodCalledToMethodSuffix[mName];
    Element.prototype[mName] = /** @function 
                               * @param name 
                               * @param value */function (name, value) {
        if (arguments.length === 1) {
            if (typeof name === 'object') {
                var elt = this[0],
                    fn = elements['set' + mEltSuffix];
                _Object$keys(name).forEach(name, /** @function 
                                                 * @param key */function (key) {
                    fn.call(null, elt, key, name[key]);
                });
                return this;
            }
 
            return elements['get' + mEltSuffix].call(null, this[0], name);
        }
 
        elements['set' + mEltSuffix].call(null, this[0], name, value);
        return this;
    };
 
    ElementsArray.prototype[mName] = /** @function 
                                     * @param name 
                                     * @param value */function (name, value) {
        /*#if DEV*/
        if (value === undefined) {
            throw new Error('Cannot get ' + mName + '  from an list of elements');
        }
        /*#/if*/
        this._forEach( /** @function 
                       * @param e */function (e) {
            elements['set' + mEltSuffix].call(null, e, name, value);
        });
        return this;
    };
 
    Element.prototype[mName].displayName = ElementsArray.prototype[mName].displayName = mName;
});
 
('setAttributes setAttribute setProperty setClass setId addClass removeClass toggleClass' + ' setValue setStyle').split(' ').forEach( /** @function 
                                                                                                                                      * @param mName */function (mName) {
    elements.addMethodWithArgumentsReturnThis(mName);
});
 
/**
 * Get the value of an element
 *
 * @name Element#getValue
 * @method
 * @return {*}
 */
 
/**
 * Get the inner content as html
 
 * @name Element#getHtml
 * @method
 * @return {String|null}
 */
 
/**
 * Get the inner content as text
 
 * @name Element#getText
 * @method
 * @return {String|null}
 */
 
'getValue getHtml getText'.split(' ').forEach( /** @function 
                                               * @param mName */function (mName) {
    Element.prototype[mName] = /** @function */function () {
        return elements[mName].call(null, this[0]);
    };
 
    Element.prototype[mName].displayName = mName;
    try {
        Element.prototype[mName].name = mName;
    } catch (e) {} // some browsers doesn't like redefining the name of a function
});
 
/**
 * Get an attribute of an element
 *
 * @name Element#getAttribute
 * @method
 * @param {string} attributeName
 * @return {string}
 */
 
/**
 * Get a property of an element
 *
 * @name Element#getProperty
 * @method
 * @param {string} propertyName
 * @return {*}
 */
 
'getAttribute getProperty matches hasClass getStyle getIntStyle'.split(' ').forEach( /** @function 
                                                                                     * @param mName */function (mName) {
    elements.addElementMethodWithArgumentsReturnResult(mName);
});
 
/**
 * Remove an attribute of an element
 *
 * @name Element#removeAttribute
 * @method
 * @param {string} attributeName
 * @return {Element}
 */
 
'removeAttribute'.split(' ').forEach( /** @function 
                                      * @param mName */function (mName) {
    Element.prototype[mName] = /** @function 
                               * @param arg */function (arg) {
        elements[mName].call(null, this[0], arg);
        return this;
    };
 
    Element.prototype[mName].displayName = mName;
    try {
        Element.prototype[mName].name = mName;
    } catch (e) {} // some browsers doesn't like redefining the name of a function
});
//# sourceMappingURL=dom.js.map