Elementals.js

Latest Version: 3.7 Final 20 December 2018

Legacy ChangeLog

Go here for the latest changes

Dates for "public" releases are the day it was -- or is planned to be -- released, whilst dates for "internal" releases reflect the day the version number was issued to the codebase.

3.4 Production, 17 November 2017 (Public Release)

Bugfix release

  • FIXED bug in 'after' parameter of _.Node.write
  • FIXED code redundancy between _.Node.write and _.make
  • ADDED Multiple properties and polyfills to _.Math incliding EPSILON, MAX_SAFE_INTEGER, MIN_SAFE_INTEGER

3.3 BETA, 16 November 2017 (Internal)

Testing further changes to _.make and _.Node.write

3.2 PRODUCTION, 14 November 2017 (Public Release)

Changes were so minor and worked well enough we're skipping the internal testing cycle and releasing early. Hopefully this won't whip around and bite us in the tuchas.

3.2 RC 1, 12 November 2017 (internal)

  • COMPLETED rewrite of how _.Node.write is handled internally to allow lookups of what write methods are available.
  • COMPLETED Addition of "children" attribute to _.make to allow more rapid deployment of DOM based content without resorting to innerHTML.
  • COMPLETED New polyfills and extensions for the Number and Math objects.
  • COMPLETED String.htmlSpecialChars

3.1 PRODUCTION, 6 November 2017 (Public Release)

First version to pass quality testing internally. Sadly the automated deployment messed up a few things hence a quick re-upload.

  • Passed internal testing

3.0 RC 1, 17 July 2017 (Public release)

A few bugfixes after stress testing legacy IE, but nothing major so RC and public release here we come. So many changes to the website between live and local, here's hoping I don't screw this up.

  • COMPLETED The reference section has now been completely rewritten to match the current version of elementals.js, with a new navigation subsystem to aid in getting around it. The GIANT master list of "underscore" properties was getting a bit unweildy when you just wanted one of the subsection. The change in the codebase to sub-objects like _.Class, _.Node, and so forth greatly aided in making the documentation easier to follow and the codebase itself easier to maintain.
  • TO-DO Update the underying website code so that the content area method/propery lists uses the same data sources as the sidebars.

3.0 Beta 4, 15 July 2017 (internal working group only)

  • FIXED Forgot that "delete" is a reserved word in legacy IE, so using it as a method name on a object we have to wrap it in quotes when creating it for IE8/earlier.
  • "this" fails in callbacks, so optimization to reduce code footprint by using "this" instead of _.Class were removed.
  • TO-DO Write the naming conventions page, and possibly a glossary of terms since I'm using Object/method/property/parameter in the classical OOP sense which may confuse folks coming from 'pretend' oop languages like PHP.
    COMPLETED 17 July 2017

3.0 Beta 3, 3 July 2017 (internal working group only)

I moved all "underscore" methods and objects that do not rely on local variables to outside the self-instancing function where we declare "underscore" in the global scope. This appears to speed up starting time in legacy IE (thanks to @KarmaWulf for pointing out the odd lag in IE7 -- dude, gimme a link, want to credit you on that) and somehow, despite being the same code knocked 200 bytes off the gzipped/minified size.

NOT sure how that works, but I'm going to dig into re-arranging the code to see if I can find other ways to trigger gzip optimizations. I know nesting 'like' code that uses the same variable names often puts them into the same 'blocks' where repeated phrases are more efficient... gah, I'm getting byte-obsessed again; and there's a difference between sane minimalism and pointless obsession.

  • Refactoring Moved all "underscore" objects/methods that don't rely on local variables or functions outside of the self-instancing function. This required rewriting all objects/methods inside the isolated scope to add themselves to the object instead of being part of it. @Tim, you seem good at catching stupid bugs/typos, could you take a look to make sure I didn't make a right mess of that?
  • Refactoring After some thought tweaked all the typeof comparisons to be value first, again seems to gzip smaller.
  • Added Start/end comments to major blocks. Generally I'm not a fan of them in my own scripting since "what's wrong with indents" but I realize that this project isn't just about ME. Much like my distaste for colour syntax highlighting and excess spaces around operators, I can work with it if everyone else finds it easier... just don't expect me to jump up and down for joy about it.
  • FIXED Bug in _.writeToClipboard that was causing IE10 to crash out due to being in "use strict". A number of other problems in terms of left/right hand evaluation orders were found across the code where IE10's version of "use strict" appears to be stricter than any other browser -- INCLUDING IE11 or Edge! Interestingly the problem does not occur in Win 10's IE10 emulation under IE11, but DOES occur in IE10 emulation under Windows 8.1 and of course, REAL IE10 in a VM. 😏
  • TO-DO More rigourous testing under REAL IE versions 5.5 through 8.
  • TO-DO Proposed site layout changes for desktop are approved and working, but breaks the media queries for mobile. Have to rethink/redo all the queries.

3.0 Beta 2, 20 June 2017 (internal working group only)

I am HOPING that this release will with minimal changes/fixes become our release candidate for version 3.0. While those of you working on internal testing and commenting run it through the ringer, I'm going to devote probably the next THREE WEEKS MINIMUM to redoing major parts of the website to make the documentation easier to navigate. Likewise all the demo code is starting to age poorly after the conversion from 2.0 to 3.0, so I'm going to set about cleaning that up as well before we go with calling it a release candidate.

Note that when we all write off on it as being suitable for being a release candidate, that will be when version 3 will go public. I took the earlier beta versions public a bit too soon, and called it "verson 2" way too soon as well... live and learn.

This time let's dot those t's and cross those i's first.

  • FIXED Stupid typo in ajax extension getXMLValuesByTagName
  • Refactored Many functions to re-use their parameters internally instead of creating new "variable for nothing", as well as using extra "undocumented" parameters to save on saying "var" unnecessarily in terms of creating local variables. In certain objects like EventAdd this seemed to clear up a problem with some local variables going AWOL in IE8/earlier too so... less code AND bugfix? Win/win!
  • QUESTION What does the working group thing on the idea of adding support for internationalization of language strings though a central object on things like the default _.Throw messages? Part of me thinks it might decrease the codebase size, part of me is worried that might be getting too complex for its own good.
    REJECTED 24 June, 2017

3.0 Beta 1, 9 June 2017 (internal working group only)

I consider this release to be feature complete, debugging and testing can begin apace.

  • Unified the old internal "log" Object with _.Log -- was no reason for them to be two separate codebases.
  • Moved and extended scroll handling into _.Metrics.Scroll which can pull the internal height/width of an elements contents, uses the elements size to determine the maximum x and y scrolling values, and of course wraps reading the x and y scroll amounts in a cross browser fashion.
  • Modified With the lifting of the raw unminified filesize restriction a major refactoring of all functions was done so that they use more verbose variable names internally. After all any good minification routine will reduce most of them to single letters anyways.
  • Switched from our own internal script minification routine to Google's Closure Compiler. It has a nice REST API for the back-end to leverage when it is update time, and while not as cutthroat on minification as our custom routine was, our in-house one was being rewritten for each and every blasted new build to try and squeeze every last byte out of it... and while I'm all about minimalism in my code, there's that line where it turns into an unhealthy byte obsession.
  • Added captureLevel property to _.Event.add and now am using the EventAdd internal callback for event handling (previously called IEEvent) to implement it in modern browsers as well. This means you can 'prevent' the object from bubbling by passing 'true' or '1', and propagating (returnValue, preventDefault, stopPropagation) by passing '2'. False/null/0 of course is the same as passing false to addEventListener.
  • Renamed _.Node.add to _.Node.write which seemed more appropriate given that the function now handles insertion at the beginning and end of an elements contents, before or after an element, or even replacing the element or its contents.

3.0 Alpha 2, 20 April 2017 (internal working group only)

The rework of the code has freed up a lot of space once everything is gzipped. To that end I'm lifting the size restrictions for the raw/non-minifed version of the program AND the minified. Really the only two numbers that should matter anyways are the gzipped sizes of both normal and minified, which will now be set to 12k and 8k respectively. If any new functionality, features, or non-essential changes will make the gzipped version of the code exceed 12k, or the minified gzipped exceed 8k, such changes will [b]NOT[/b] be accepted into the codebase!

This newfound space has been used to add the following:

  • Added _.Cookies Object containing easy methods for cookie manipulation. This was a pretty big gap in functionality given any library/framework worth its salt should have this.
  • Added _.EMPTY_TAGS and _.NON_CONTENT_TAGS "constants" to aid in error checking/validation of passing certain element types to certain methods/functions. I also personally just find it handy to have them readily available.
  • Added _.Metrics Object to make figuring out where and how elements are sized a bit easier.
  • To-Do Move scrolling routines into _.Metrics --- possibly as methods of a sub-object? Opinions?
    Completed 3.0 Beta 1, 9 June 2017
  • Added _.Select Object to make clipboard selection more versatile.
  • Added _.writeToClipboard method for cross-browser pasting to the clipboard of any string/variable you want. Not supported in all browsers as I didn't think adding a flash fallback was appropriate. REALISTICALLY any modern browser and even most versions of IE should work without that now.
  • Moved _.BROWSER_PREFIXES from being a local variable hidden from users to client-facing. It's useful enough that if we're gonna have it in the codebase, might as well let people have it.

3.0 Alpha 1, 12 April 2017 (internal working group only)

Project was put on the back-burner breaking the planned release schedule since full time paying job comes before side projects like this one. Working on the paying job and listening to feedback from those of you brave enough to try this has made me consider radical changes to how elementals works and is laid out.

After much deliberation and re-writing the documentation I came to the conclusion that re-organizing the functionality into further sub-objects inside the "underscore" element would ease in maintaining the documentation, organizing the code, and creating a more 'navigable' website for the project. I think the result is overall clearer though it completely breaks 2.0/earlier support.

To that end, too many changes to document as it's a mostly new codebase.

2.0 RC 3, 14 March 2017

Due the relatively small changes and additions, this version is NOT pushing the planned production release of 25 March 2017 ahead any.

  • Added "replace" type to _.nodeAdd and any associated functions that rely upon it such as _.make
  • FIXED bug in JSON.serialize polyfill. Pretty much a stupid typo.
  • FIXED bug in x.getXMLValuesByName -- another minor typo.
  • Optimized _.nodeAddSelectButton by removing some redundant logic.
  • Optimized _.make reduced code size by re-arranging order of trapping special functions/handling in attribute object.

2.0 RC 2, 4 March 2017

Was not originally planning on a RC2, but suggestions from the peanut gallery prompted the addition of some new features and one pretty big change in behavior.

  • Added Several new simple methods for determining scrolling information about a page. Specifically:

    1. _.scrollMaxX
    2. _.scrollMaxY
    3. _.scrollX
    4. _.scrollY
  • Added Some new String methods.

    1. String.pad
    2. String.strFrom
  • FIXED Bug where cross-browser auto-fix for internally prefixed object methods was missing from codebase. I thought things felt a bit lightweight. Required for:
  • Added Polyfills for performance.now, Window.requestAnimationFrame, and Window.cancelAnimationFrame. I used a varient of the ones Erik Möller put up over on "My Opera" a few years ago, that now seems to have gone AWOL since, well... "My Opera" went the way of the dodo. Mine differes in that I have an internal function in place to check and replace for browser prefixed versions already, I have a wee bit different a way of iterating arrays I know the contents of, I polyfill performance.now so that's used for the timer, I set 16.666667 instead of a flat 16 for the timer interval to be closer to the common 60fps, and I directly copy Window.clearTimeout to Window.cancelAnimationFrame as there is no legitimate reason to wrap that since, well duh, an instance of Window is an instance of Window. It should also start up way faster than his since it does not just blindly assign values to Window to then check.
  • Added eSmooth.js sub-library to site and downloadable distro.
  • Revised _.queryAll will now return an empty array on ALL matches. This makes it easier to use Array.forEach on it without YOU having to hard code a return check.

These changes push the move from "Release Candidate" to "Production" ahead to 25 March 2017.

2.0 RC 1, 25 Februrary 2017

  • FIXED Spelling error in _.throwRange
  • FIXED Array.of added directly instead of by Array.prototype.of
  • FIXED String.repeat FINALLY working as it should.
  • FIXED _.queryAll now returns array in ALL browsers. Had to brute force it since apparently IE8 does support Element.querySelectorAll, but does NOT support Array.prototype.slice.call on a NodeList. DERP... no, seriously, what the hell? TEMPTED to polyfill Array.prototype.slice but is it worth the code for such a minor corner case?
  • FIXED bug in _.make that was broken by fix to application of 'type' attribute.
    This resulted in:
  • Refactored Internal eAddAttr function folded into _.make and greatly simplified. Originally had it recursive for support of objects inside objects, but data- attributes may have objects passed to them. The only object that "needs" to be parse is Element.style so I just special cased that one. Switched 'type' to a special case as well and reorganized the parsing order. New routine tested at five to fifteen percent faster depending on browser, seems more reliable, and is less code to boot!
  • Changed normalized some of the polyfills to be more consistent with the specification behaviors.

2.0 Beta 10, 24 Februrary 2017

  • Revised The three _.callbackArray methods have been moved to be extensions to Array instead. They are now:

    1. Array.callbackAnd
    2. Array.callbackAndAll
    3. Array.callbackOr
    This made more sense given what they do and how they do it. It also shaved a wee bit off the codebase size.
  • FIXED Documentation for _.scriptAdd outdated. Was still written as if the second parameter was the boolean async and not an object containing attributes to be added to the generated SCRIPT tag.
  • FIXED Bug in Array.callbackOr that would have prevented it from doing more than one true answer. DOH. Or should be inclusive like Array.callbackAndAll
  • FIXED Bugs in _.nodeCountAll and _.nodeCountChildren where parameters passed to _.nodeEachAll and _.nodeEachChild were reversed.
  • Bug Misspelt "Infinity" in _.throwRange
    FIXED 2.0 RC 1, 25 February 2017
  • Bug Array.of cannot be added via Prototype, must be direct.
    FIXED 2.0 RC 1, 25 February 2017
  • Bug CHRISTMAS ON A CRACKER!!! String.repeat STILL bugged!!
    FIXED 2.0 RC 1, 25 February 2017
  • Bug attr.style broken on _.make after fix for IE type="" attribute
    FIXED 2.0 RC 1, 25 February 2017
  • Issue _.queryAll on modern browsers returns a nodelist, but the legacy polyfill returns an Array. Question is, which is more useful? With the enhanced Array methods of ECMAScript 5/newer perhaps the Array would be the better choice?
    Resolved 2.0 RC1, 25 February 2017 -- forcing modern browsers to return Array

2.0 Beta 9, 23 February 2017

  • FIXED typos in _.nodeAddSelectButton
  • FIXED missing () in _.nodeSelect IE compatibility.
  • Refactored _.nodeSelect so that only the browser specific version needed is in fact used during runtime.
  • FIXED _.formSerialize handling of empty form elements.
  • FIXED _.formSerialize so it will use the text content of an OPTION tag as value if no value is specified, as per the HTML behavior of a form submit.
  • Bug Array.callbackOr Not iterating all results?!?
    FIXED 2.0 Beta 10, 24 February 2017
  • Bug _.nodeCountAll and _.nodeCountChildren parameters passed to _.nodeEachAll and _.nodeEachChild are reversed.
    FIXED 2.0 Beta 10, 24 February 2017

2.0 Beta 8, 21 February 2017

  • FIXED missing internal escFunc
  • FIXED Logic flow issue in String.repeat polyfill. Excellent example BTW of what pisses me off about C syntax and just how far away from how Assembly works every single language based on it is. ZERO way to check flags AFTER a shift operation, and no concept of a rotate... It's sad when certain tasks are actually simpler to code in machine language.
  • Bug typos preventing _.nodeAddSelectButton from working.
    FIXED 2.0 Beta 9, 23 February 2017
  • Bug _.nodeSelect not calling getRangeSelect as method.
    FIXED 2.0 Beta 9, 23 February 2017
  • Bug _.formSerialize passing empty form elements.
    FIXED 2.0 Beta 9, 23 February 2017
  • Bug When HTML encounters an OPTION tag that has no value, it will pass the content of that tag as the value server side during normal form handling. It appears that Element.value is NOT populated by any browser if the value is not explicitly stated, meaning that default behavior was not implemented in _.formSerialize.
    FIXED 2.0 Beta 9, 23 February 2017

2.0 Beta 7, 19 February 2017

  • Internal Using own minifier as most existing ones seem to choke on certain aspects of how Elementals works. Will have to test in detail this minifier just to be sure it's not screwing things up beyond repair. Customizeed specifically for elementals so most likely it would be highly inefficient for any other codebase.
  • Optimize Used shorter single letter parameters in codebase, but did so in a consistent manner. If you want to know the full name of the variable when browsing the code, refer to the corresponding reference page.
  • Website Added distro package to downloads containing the most recent versions of elementals.js, elementals.min.js, and the various live demos.
  • Website Added stats tracking to home page to keep track of the various sizes and bandwidth elementals.js uses depending on what version is used and how you serve it.
  • FIXED Stupid "bug" where _.log(msg, 'alert'); wouldn't function in some browsers because of how jacktarded JavaScript's use of scope is when using literal notation on an object. Thanks to Goos over on codingforums for pointing out that issue and the Array.reduce flaws that were fixed in beta 6.
  • To-Do Hey, where the blazes did the license agreement go?!? I can't even find the bloody file! Hoping it didn't go awol and I end up having to rewrite that from scratch, even if it is my stock "to blazes with open sores, if you're gonna give something away give it away" rant.
    FIXED interim site update
  • Bug Failed to port escFunc, so JSON polyfill broken in legacy IE.
    FIXED Beta 8, 21 February 2017
  • Bug String.repeat polyfill has nonsensical binary logic... no internal check of value shifted off the count.
    FIXED Beta 8, 21 February 2017

2.0 Beta 6, 18 February 2017

  • FIXED bug in Array.reduce and Array.reduceRight
  • Documented _.uSortRestore
  • Added more transparent handling of event callbacks, resulting in:
  • removed _.eventProcess as pointless redundancy.
  • To-Do Document changes to demo documentation due to removal of _.eventProcess
    Documented interim site update

2.0 Beta 5, 17 February 2017

  • FIXED bugs in _.uSortElement
  • Added _.uSortRestore function to return list to original window load state.
  • Modified large sections of the codebase. Some size optimizations, a good deal of speed optimizations such as making frequently called callbacks static instead of having them as anonymous functions.Even with the added functionality, the overall codesize has not grown significantly since Beta 4.
  • To-Do DOCUMENT _.uSortRestore and add functionality to the demos.
    Documented Beta 6, 18 February 2017
  • BUG Array.reduce and Array.reduceRight written for numeric processing only, should be able to handle strings.
    FIXED Beta 6, 18 February 2017

2.0 Beta 4, 17 February 2017

  • FIXED Legacy IE bug regarding direct assignment vs. Element.setAttribute. Created new internal objAttrSet function to handle correct passing of object parameters (such as style) to attributes whilst still passing 'nodePlacements' and 'content' type 'extraNodes'. Debating on if function should be exposed interface-side.
  • Website made changeLog its own page, it's big enough now!
  • Bug _.uSortElement utterly banjaxed.
    FIXED 2.0 Beta 5

2.0 Beta 3, 16 February 2017

  • FIXED bugs in onprogress handling and various other small quirks in the _.ajax handler.
  • FIXED bug in _.make that resulted in trying to set Element.onclick fail to function. Apparently you can't set an anonymous function using Element.setAttribute. I didn't know that!
  • Documented _.nodeData
  • Bug Legacy IE will not set unknown 'type' on input using direct assignment, must use setAttribute. IE will not set functions on Element without direct assignment! Gonna have to trap BOTH to use the correct method.
    FIXED 2.0 Beta 4.

2.0 Beta 2, 12 February 2017

  • FIXED numerous typo's
  • FIXED _.nodeNext was still written to old Element extension model from 1.0, making it non-functional. Odd that _.nodePrev was correct given they're pretty much the same thing.
  • FIXED _.classToggle wasn't returning boolean true or false, an essential part of its functionality.
  • FIXED _.nodeData function missing, copied from 1.0 and updated to work with new structure
  • Added _.NODEMASK_type constants.
  • To-do _.nodeData documentation.
    Documented in Beta 3

2.0 Beta 1, 10 February 2017

  • First public release after relaunch of project

ERROR, could not find "oldChangeLog"

Downloads

Advertisement