13 April 2018 - Elementals 3.6.4 Relased!
By Jason M. Knight (aka Deathshadow)

Elementals.js

This latest update to elementals.js brings with it some code efficiency improvements that speeds up some functions and shrunk others, making room for some new functionality. At 7.71k in size gzipped and minified it still fits under the 8k hard ceiling we have set for a code limit... more than enough room to add a few new features shoould anything come up.

The most noteworthy addition to the codebase is the forceThis argument on _.Event.add(), which lets you pass an object that inside the event callback will be treated as the this object. It is passed using Function.call() so that the headaches -- and legacy compatibility woes -- of Function.bind don't get involved. Be warned though, this means that if you omit said parameter inside your event callbacks this will be NULL.

String.splitSelector has been changed to return a null string instead of "DIV" when no tagName is included in a DSS. This simplifies loose boolean tests when needed and reduced the overall code size. The default in a DOM-JON of an empty tag-name defaulting to DIV is now handled inside _.make().

The "fast content selector" for DSS has been changed so that for OPTION tags it is applied as text content, not VALUE. To set the value on a OPTION tag you should be using the "speical value selector" instead.

I'm still banging my head against the wall undoing code revisions made by a former team member that just plain broke a number of things. The AJAX getXMLValuesByTagName implementation for example was using the wrong for loop style which resulted in the limit parameter being ignored. Whilst the "iterate by value" appraoch is faster and one I advocate, it was completely the wrong tool for the job there! It's almost like when I showed it to the person in question they just started blindly applying it to everything... In another spot I found two routines were source-order swapped when the source order actually mattered!

But for all that I'm finally getting it hammered out how I originally envisioned the whole thing. The creation of DOM-JON as a separate "specification" separate from elementals.js has not only made documentation of it easier to create and maintain, it has also let me focus more clearly on the implementation and how both _.make and _.Node.write interact with it. At the start I never envisioned having a full-on structure for mass creating HTML from JavaScript directly on the DOM... but the more I work with it the more I realize it's something people have been doing for ages with innerHTML regardless of the performance penalties or headaches caused in trying to work with that appraoch. Assigning any created elements with ID's to a object by ID (thanks Tim Darrel for the suggestion) has made accessing the elements BEFORE script execution ends AND in a manner that is in fact faster than getElementById has proven efficient and powerful.

Now I just REALLY need to get off my arse and write some REAL tutorials about it.

As always if you find any bugs or issues please report them through the contact form on the official site.

Projects

  • elementals.js
    A lightweight JavaScript library focusing on cross browser support, ECMAScript polyfills, and DOM manipulation.
  • eFlipper.js
    An image carousel script using elementals.js
  • eProgress.js
    A JavaScript controllable progress bar using elementals.js. Based on the nProgress project that relies on the much heavier jQuery library.

/for_others

Browse code samples of people I've helped on various forums. These code snippets, images, and full rewrites of websites date back a decade or more, and are organized by the forum username of who I was helping. You'll find all sorts of oddball bits and pieces in here. You find any of it useful, go ahead, pick up the ball, and run with it.

Advertisement

Best Viewed With Eyeballs