Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

DOMAssistant 2.7 released: better performance, more features, smaller file size

DZone's Guide to

DOMAssistant 2.7 released: better performance, more features, smaller file size

· Web Dev Zone
Free Resource

Start coding today to experience the powerful engine that drives data application’s development, brought to you in partnership with Qlik.

Original post written by Robert Nyman : Original Post

After a lot of hard work, we’re more pleased than ever to present the new version of DOMAssistant: faster, less code, better support and improved stability. And more features, of course. :-)

While we have actually made the code file size smaller, at the same time we have added a number of useful features and improved CSS selector performance.

New features

Unicode support added

In this version, we focused a lot on delivering Unicode support, implying support for basically any source document language. The web is, as you know, very international and it felt a bit hindering to only support English properly.

Naturally, we also wanted to measure up to other JavaScript libraries, and therefore we created the Slickspeed Unicode test to show what we have accomplished. Hint: the DOMAssistant column is the one getting it right. :-)

Complete documentation in Chinese

In line with our Unicode support, we now also offer complete documentation in Chinese (and as of before, in French). These translations are available as downloads from the documentation section.

New methods: cssSelect, ajax, setStyle, setErrorHandling and first

A number of new useful methods, after getting feedback from users and the community, have been introduced with this release:

cssSelect

This method is used to perform a CSS selection on an already existing DOM element reference. Example:

$(document).cssSelect(".mandatory");

$$(DOMElementReference).cssSelect(".important[type=test]");).

ajax

The ajax method is a more detailed and precise way to perform AJAX operations, where the web developer can fine-tune a lot of settings. E.g.:

$("#container").ajax({
url: "ajax.php",
method: "POST",
params : "name=DOMAssistant",
callback: functionReference,
headers : {
"Content-type" :
"application/x-www-form-urlencoded"
}
});

setStyle

To apply direct inline styling to an element, to override CSS applied from a CSS file or if you need to change something dynamically, you can use the setStyle method. Example usage:

$("#container").setStyle("border", "10px solid red");

$("#container").setStyle({
background : "#ffffa2",
color : "#f00"
});

setErrorHandling

When using the DOMAssistant.DOMReady method to add functions/methods to run as soon as the DOM is loaded, there’s now an alternative to set an error handler if it fails:

DOMAssistant.DOMLoad.setErrorHandling(function (e) {
// e is the error object passed in
});

first

This is a helper method to get a reference to the first item returned in a CSS selection, and adding all the DOMAssistant methods to that element as well. For example:

$("#navigation a").first();

Vastly improved CSS selector performance

Another thing that we in the DOMAssistant team is very important, and sometimes underrated by people, is performance and accuracy. With version 2.6 DOMAssistant had the overall fastest CSS selector performance, except for in Internet Explorer, where Ext JS had very impressive results performance-wise.

We took that as a challenge, and improved the code for most web browsers while also seeing to that DOMAssistant now generally has the fastest CSS selector performance in Internet Explorer as well (results may vary…).

Try the Slickspeed test to see the new results!

Fixes and accuracy changes

Another thing we have done is fixing the accuracy of some CSS selectors, and general method behavior has been modified to minimizing the risk for errors and delivering a more stable experience.

  • Fixed so a function for an event, applied with addEvent, couldn’t be added multiple times.
  • Fixed so a function in DOMReady couldn’t be applied multiple times.
  • Accuracy fixes for XPath’s ends-with() implementation of E[att$=value].
  • Accuracy fixes for nth-child selector.
  • Accuracy fixes for ~ selector and contains in Internet Explorer.
  • Fix for what’s allowed following a child/sibling combinator.
  • Fix for attribute selector to support values that contain spaces.
  • Fix for what’s returned from the prev and next methods, so it has the correct methods applied.

Give it a go!

We are very happy with this release and would love for you to download DOMAssistant and try it out.

Join us in the world DOMination! :-D

Create data driven applications in Qlik’s free and easy to use coding environment, brought to you in partnership with Qlik.

Topics:

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}