ebollens / dom_mapper

Lightweight rule engine that maps attributes onto a semantic structure

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DomMapper

DomMapper is a lightweight rule engine that maps attributes onto a semantic structure.

Status

The code in this repository is under development and not intended for production use at this time.

License

DomMapper is open-source software licensed under the BSD 3-clause license. The full text of the license may be found in the LICENSE file.

Credits

DomMapper is developed and maintained by Eric Bollens.

DomMapper leverages several open-source components, including Specificity and ES5 array polyfills on the Mozilla Developer Network. A sincere thanks is extended to the authors of these fine projects.

Build

To pull dependencies required to build:

npm install

To generate a build:

node_modules/grunt-cli/bin/grunt

This will produce several files into dist (and their minified .min.js equivalent):

  • dom_mapper-core.js - DomMapper class definition (must be included)
  • dom_mapper-polyfills.js - ES5 Array polyfill (for Internte Explorer 7 & 8)
  • dom_mapper-rules-aria_mappings.js - Common ARIA rulesets

Use

DomMapper.run(AriaMappings.Html5.All);
var rules = [].concat(
  AriaMappings.Html5.Landmarks,
  { type: "role", role: "search", selector: "nav.search" },
  { type: "role", role: null, selector: ".no-role", specificity: "1,0,0,0" }
);

DomMapper.run(rules);
var factory = new DomMapper.RulesFactory();

factory.append(AriaMappings.Html5);

factory.append([
  { type: "role", role: "search", selector: "nav.search" },
  { type: "role", role: null, selector: ".no-role" }
]);

factory.generate().run();

Test

To pull dependencies required to test:

npm install

To run the jshint and qunit tests:

node_modules/grunt-cli/bin/grunt test

To view qunit test results through an interface, go to test/index.html.

About

Lightweight rule engine that maps attributes onto a semantic structure

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:JavaScript 100.0%