Skip to content

Features and compliance

dperini edited this page Sep 13, 2010 · 3 revisions

The following is a mostly complete list of the engine features:

  • CSS3 compliance with latest W3C specifications and syntax rules
  • accept HTML, XHTML, XML documents and DOMFragment contexts
  • can query documents both in different windows and/or different frames
  • full Unicode character support for extended internationalization coverage
  • correctly allows for escaped character codes (\\) in id/class selection strings
  • complete CSS3 selectors support, including -of-type selectors, :root, :target
  • case sensitivity/insensitivity correctly checked for each different attribute values
  • accept complex selector syntax and allow for multiple and nested :not() selectors
  • returns result sets are pure Array objects and the “document order” is maintained
  • full feature test and bug detection for most bugs, completely avoid browser sniffing
  • boosting caching system based on Mutation Events for browsers that support this feature
  • pure Javascript engine with no external dependance, only 5Kbye compressed code size

Explicit bug-defeating related features:

  • correct form selection problems where form elements overwrite DOM properties
  • correct most bugs related to wrong selection due to id/name attributes overwriting
  • correct IE problems with gEBTN returning “comment” nodes in the result collection
  • alternative path for buggy browsers implementation of latest Selector API (Safari, IE8)

Several parts of the engine are now exposed as public methods but the two most important methods are:

NW.Dom.match( element, selector, context, callback )

Matches an element with a given CSS selector in the specified context and returns “true” if it does, “false” otherwise.

Optionally execute a “callback” function, passed as fourth parameter, if the element matches the selector. The callback is passed the element as first argument.

This is the core “bottom-up” matcher implementation, the passed CSS selectors are converted to ad-hoc Javascript function resolvers and saved for later reuse.

Especially useful in the implementation of an “event delegation” system and to quickly traverse a tree of specific elements.

NW.Dom.select( selector, context, callback )

Select a subset of elements matching the given selector from the current document or the specified context.

Optionally execute a “callback” function, passed as third parameter, for each iterated element that matches the selector. The callback is passed the element as first argument.

The passed selector string can contain several CSS selectors separated by commas (selector group).

The selection functionality is based on the “bottom-up” matcher but for performance several optimization are executed to reduce the number of elements that will be scrutinized.

Clone this wiki locally