# Yahoo! UI Library

### yui 3.3.0

Yahoo! UI Library > yui > features.js (source view)
Search:
Filters Show Private Show Protected Show Deprecated

    var feature_tests = {};

    Y.mix(Y.namespace('Features'), {

        tests: feature_tests,

        add: function(cat, name, o) {
            feature_tests[cat] = feature_tests[cat] || {};
            feature_tests[cat][name] = o;
        },

        all: function(cat, args) {
            var cat_o = feature_tests[cat],
                // results = {};
                result = '';
            if (cat_o) {
                Y.Object.each(cat_o, function(v, k) {
                    // results[k] = Y.Features.test(cat, k, args);
                    result += k + ':' +
                           (Y.Features.test(cat, k, args) ? 1 : 0) + ';';
                });
            }

            return result;
        },

        test: function(cat, name, args) {
            args = args || [];
            var result, ua, test,
                cat_o = feature_tests[cat],
                feature = cat_o && cat_o[name];

            if (!feature) {
                Y.log('Feature test ' + cat + ', ' + name + ' not found');
            } else {

                result = feature.result;

                if (Y.Lang.isUndefined(result)) {

                    ua = feature.ua;
                    if (ua) {
                        result = (Y.UA[ua]);
                    }

                    test = feature.test;
                    if (test && ((!ua) || result)) {
                        result = test.apply(Y, args);
                    }

                    feature.result = result;
                }
            }

            return result;
        }
    });

    // Y.Features.add("load", "1", {});
    // Y.Features.test("load", "1");
    // caps=1:1;2:0;3:1;

Copyright © 2011 Yahoo! Inc. All rights reserved.