Return the current value of the named feature.

Returns the value of the feature named by name. The feature must have been previously added to the cache by has.add.


Parameter Type Description
name String | Integer

The name (if a string) or identifier (if an integer) of the feature to test.

Returns: boolean

See the dojo/has reference documentation for more information.



Defined by: dojo/has



Defined by dojo/has

Register a new feature test for some named feature.

Parameter Type Description
name String | Integer

The name (if a string) or identifier (if an integer) of the feature to test.

test Function

A test function to register. If a function, queued for testing until actually needed. The test function should return a boolean indicating the presence of a feature or bug.

now Boolean

Optional. Omit if test is not a function. Provides a way to immediately run the test and cache the result.

force Boolean

Optional. If the test already exists and force is truthy, then the existing test will be replaced; otherwise, add does not replace an existing test (that is, by default, the first test advice wins).

Returns: undefined


Example 1

A redundant test, testFn with immediate execution:

has.add("javascript", function(){ return true; }, true);

Example 2

Again with the redundantness. You can do this in your tests, but we should not be doing this in any internal has.js tests

has.add("javascript", true);

Example 3

Three things are passed to the testFunction. global, document, and a generic element from which to work your test should the need arise.

has.add("bug-byid", function(g, d, el){
    // g    == global, typically window, yadda yadda
    // d    == document object
    // el == the generic element. a `has` element.
    return false; // fake test, byid-when-form-has-name-matching-an-id is slightly longer


Defined by dojo/has

Deletes the contents of the element passed to test functions.

Parameter Type Description
element undefined


Defined by dojo/has

Conditional loading of AMD modules based on a has feature test value.

Parameter Type Description
id String

Gives the resolved module id to load.

parentRequire Function

The loader require function with respect to the module that contained the plugin resource in it's dependency list.

loaded Function

Callback to loader that consumes result of plugin demand.


Defined by dojo/has

Resolves id into a module id based on possibly-nested tenary expression that branches on has feature test value(s).

Parameter Type Description
id undefined
toAbsMid Function

Resolves a relative module id into an absolute module id

© 2005–2017 JS Foundation
Licensed under the AFL 2.1 and BSD 3-Clause licenses.