Elementals.js

Latest Version: 3.6.4 PRODUCTION 13 April 2018

ChangeLog

Action Colour Key

  • Bugfix or other information that does not impact how the API is called by end developers.
  • Changes that indicate new functionality
  • Unfixed Bug Report
  • These changes cause fundemental changes in the API, such as removal or renaming of existing methods. Those using older versions of this library should watch for these when upgrading.

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.

4.0.0 BETA 2, 27 June 2018 (internal) 🔗

Was "4.0.0 RC 1, 21 June 2018" -- see "REVERTED" below.

Testing suite needs complete rewrite to match new functionality, this could delay production release several weeks. Tim, that's your job. You need help ASK. -- Jason

While that's going on all the changes need to be documented, I'll tackle this.

Action Regarding Description
ADDED
2 Jul 2018
13:04 EST
DOM-JON "viewProperty" _.make
_.View

Used to allow elements created by _.make to be associated with values in a view. If this is a string it is assumed a 1:1 relationship between the element's content and a property on the view. If an array, the first value is the name of the view property, and the second value is a function that will be called to populate based on the value of that property. This will allow for the creation of "templates" when complex structures such as multi-dimensional arrays and objects are view properties.

Your template callback function should accept as its parameters the parent element created by _.make, the data to be processed by the template, and an optional "row identifier" corresponding to an array index of the view property. (if any)

ADDED
2 Jul 2018
12:52 EST
Number.__floatToHex Converts a floating point number to a Hexadecimal exponent notation. Required for String.__printf, figured why not expose it for public use?
ADDED
2 Jul 2018
12:50 EST
String.__printf A reasonably complete "C Style" printf. Only %n remains unimplemented (for obvious reasons). Major functionality differences is that hex always starts with 0x with any width padding applied AFTER, octal is treated the same with a leading zero.
MODIFIED
2 Jul 2018
12:50 EST
_.Log.alert
_.Log.append
_.Log.error
_.Log.log
_.Log.warn

These methods now accept arguments in the same manner as console.log, regardless of which output type is proper/selected. Remember that some legacy browsers lack "console". If you use any _.Log method that cannot call console, the messages will be appended to document.body instead.

The String.__printf routine is used to parse the first parameter if it is a string, contains a % sign, and there are more than one paramater passed to these functions. Any arguments not parsed into the template string are output normally after it. Our own elementals.js extension was used instead of relying on window.console's in-built functionality as browser implementation is hit-or-miss-or-miss-or-miss on what is and isn't supported and how each browser handles the output.

Note that any user objects will be JSON encoded, but most system objects will return empty as JSON.Stringify cannot see most properties on things like document.body. To output node elements and the like simply don't include them in the template and pass them normally -- on browsers that support window.console they will be output correctly.

PROPOSED
2 Jul 2018
12:24 EST
IMPLEMENTED
2 Jul 2018
12:42 EST
Array, Math, Number, Object, and String extensions Change all extensions to use a identifying prefix to differentiate them from any official changes to the JavaScript / ECMAScript specification. Underscore or double underscore would suffice.
Modified
1 Jul 2018
13:16 EST
_.Log.append To better make use of _.make
BUG
1 Jul 2018
09:43 EST
FIXED
1 Jul 2018
12:50 EST
_.make Bug in application of event handler that was preventing non-array events from being applied. Typo, had [] instead of ()
REMOVED
1 Jul 2018
12:31 EST
_.Node.replace Redundant to _.Node.write(element, content, "replace");
REQUESTED
30 Jun 2018
18:20 EST
ADDED
1 Jul 2018
12:20 EST
_.View

"Views" are a way to incorporate data structures alongside a DOM-JON using JSON notation to make easy to maintain and handle data objects. If you attach a DOM-JON to the creation of a VIEW, any events inside that structure will default to the View as "this" (via Function.apply) should you not set a forceThis parameter on it, exposing any methods or variables created on the view.

This should be a much better and cleaner way of handling this than the locals and methods approach we were trying to incorporate into _.make. This is new functionality, it warrants its own separate implementation and call.

In a lot of ways we've been trying to put too many eggs into the baskets that are _.make and _.Node.write.

REMOVED
28 Jun 2018
01:30 EST
blockDisplays internal variable Legacy code left behind by the now defunct _.Node.textFormatted
REWROTE
27 Jun 2018
19:17 EST
REVERTED
28 Jun 2018
00:48 EST
iWrite internal routine

Rewritten to reduce code redundancy and to allow better/more reliable detection of valid DOM-JON placement. If you pass an string as the target element, document.getElementById will be used to find the element with _.Log.error called when not found. Otherwise it is assumed the target element is a DOM object.

The increase in code size did not match improvements in functionality. Again around 2k of code doing 200 bytes job. NOW I know why you all voted for a increase in the hard ceiling... and look, NOW we're back below 8k!

This commit was rejected by project management, and instead the old code was updated to a more verbose variable usage and better offloading of data processing.

ADDED
28 Jun 2018
00:14 EST
_.make event as array

If you pass an Array to _.make as an onevent attribute the element and event name will be shifted onto the start of the Array, and _.Event.add.apply(null, Array) will be called to create the event. This allows you to pass a "forceThis" parameter, allowing for far simpler and faster passing of data and methods to event handlers than the "locals" and "methods" approach.

Don't overthink this stuff -- that was 5k of code replaced by 131 bytes!

REMOVED
28 Jun 2018
00:05 EST
locals and methods from _.make and _.Node.write Implementation was too fragile, too complex for its own good, and introduced FAR too much overhead. This is why I don't like how things like react, angular, or vue handle things... and why we should review and brainstorm BEFORE we try implementing anything similar to how other developers do it! We can do better than this!
REQUESTED
27 Jun 2018
13:02 EST
ADDED
27 Jun 2018
13:39 EST
locals parameter to DOM-JON Creates an object containing variables that are added to the element as Element.data-_locals. If present and the forceThis parameter is not set on _.Event.add, Element.data-_locals will be used as this instead.
REVERTED
27 Jun 2018
13:34 EST
elementals.js version

Dropping this build back to BETA 2 status from RC 1. Calling this a RC was a over-idealistic case of jumping the gun. I'm half tempted to drop it to Alpha since we keep adding functionality, particularly under the new size guidelines.

CHANGED
27 Jun 2018
13:30 EST
elementals.js guidelines

Hard ceiling for gzipped minified codebase size upped to 12k after internal team vote. As benevolent dictator on the project I'm NOT happy with it, guess I'll have to take my own advice: Suck it up and deal!.

Well, it does free up room to put textFormatted back in and implement its original plan. Hmm, maybe give _.Node.toMarkdown and _.Node.fromMarkdown a second vote as a result?

ADDED
24 Jun 2018
12:54 EST
DOM-JON special attributes

New tag/attribute defaults

tagName Attribute
abbr cite
acronym cite
audio src
blockquote cite
del cite
ins cite
label for
output for
source src
track src
q cite
video src
How the blazes wasn't label already in there?
FIXED
24 Jun 2018
12:11 EST
_.make and namespaces Legacy IE has no document.createElementNS so we have to add detection for this. Make will now return boolean false if you attempt to create a namespaced element in browsers that don't support namespaces. Consider this your feature detection.
FIXED
24 Jun 2018
12:05 EST
_.Class.get Legacy IE compatibility with namespaces is a bit of a wonk, and IE 6/earlier doesn't Element.getAttribute('class'); properly. Now works all the way back to IE 5.x because... well... we can.
RESTORED
24 Jun 2018
11:23 EST
polyfills local variable Put polyfills = null; back into code after polyfills are applied. Why was this removed? Setting it to null frees up memory after we're done with it!
BUG
23 Jun 2018
21:40 EST
FIXED
23 Jun 2018
22:03 EST
_.make Element.class vs. Element.className e.setAttribute('class', dss.className) does not exist/function in IE7/earlier. Also this should be calling / be normalized in _.Class.add and NOT be handled directly in _.make.
ADDED
23 Jun 2018
21:54 EST
_.Class.get _.Class.set Use in cases where you cannot be sure what namespace -- XML or HTTP -- an element is in... since in those cases you cannot know if it's Element.class or Element.className. Be warned _.Class.set sets the ENTIRE classname, erasing any existing classes. To preserve classes use _.Class.add
ADDED
23 Jun 2018
21:54 EST
_.Class.get _.Class.set Use in cases where you cannot be sure what namespace -- XML or HTTP -- an element is in... since in those cases you cannot know if it's Element.class or Element.className. Be warned _.Class.set sets the ENTIRE classname, erasing any existing classes. To preserve classes use _.Class.add
CHANGED
23 Jun 2018
20:17 EST
_.make Element.class vs. Element.className Classes are now applied via e.setAttribute('class', dss.className) instead of via e.className = dss.className. This change means that XML elements such as those created when using SVG will get their classes set correctly, whilst still working properly on HTML elements. This change applies to both DSS and to 'class' and 'className' attributes.
CHANGED
23 Jun 2018
17:02 EST
REMOVED
23 Jun 2018
20:14 EST
_.make and
DOM-JON

If you pass a DOM-JON as the first parameter, it will return an array of the created top-level elements instead of a boolean true.

Functionality removed, caused massive slowdowns and overhead during DOM-JON parsing. You need access to elements you are creating with _.make either give them id's and check _.ids or walk the DOM.

In Soviet Russia, the DOM walks you!
CHANGED
23 Jun 2018
17:28 EST
Website ChangeLog Changelog routine on website modified to show change times in "action" column for all new reports.

Side note guys, changelog updates -- even on internal builds -- are SUPPOSED to be public so tick that bloody box! At least let people know we're still working on it!!!

4.0.0 Beta 1, 12 June 2018 (internal)

Internal development and testing branch for the 4.x release

Action Regarding Description
REVERTED dss.special dss.content The detection of these back to using an Array lookup. Was changed to switch/case in 3.6.2 but the long term the benefits were nonexistent as more conditions are added to DOM-JON. ANOTHER change that wasn't project manager approved and was the way it was for a REASON!
REMOVED _.Node.textFormatted Too specific in its usage and functionality to belong in a general purpose library. Would be better as a standalone example of how to use this library.
FIXED _.Event.add Bug where bubble preventing detection of boolean true was failing. It's === not == people! Happens to the best of us.
CHANGED _.Event.add The 'this' parameter on callbacks will no longer default to null if not specified, instead event.currentTarget will be 'this' inside your callback unless you set forceThis. Change came about during implementation of the "array of parameters" feature switching us from Function.call to Function.apply.
MODIFIED Polyfills Changed method of application slightly for size optimization
MODIFIED String.splitSelector Improved methodology to make adding more delimiters simpler.
CHANGED _.make "data-" attributes are now always added via e[attr]=value, but all others use setAttribute. Was fancier for legacy IE application of non-standard attributes -- but the addtion of namespaces and trapping "data-" attributes should be covering those bases. Need to dust off the testcases for that little legacy IE quirk.
REMOVED _.make write values Check for multiple values. Only the last one declared will be applied. Others are now ignored without error.
MOVED _.Node.dataGet Used to be _.dataGet
ADDED _.Node.dataSet Has trapping so as to avoid overwrite if value already exists. Replaces internal notSetSet function.
REMOVED notSetSet internal function. Replaced by _.Node.dataSet
REMOVED Math.clz64 JavaScript botches being able to handle true 64 bit numbers in this manner. Probably why it doesn't exist in ECMAScript.
REMOVED placement check in _.Node.write The check for "after" when placement != "Last" probably took as long if not longer to check for match than it does to just assign the value, so just assign the value!
FIXED _.String.endsWith bug -- Simple typo prevented it working
REMOVED Array.of and Array.isArray polyfills Lands sake just use [] array construction and "instanceof Array" instead. I'm starting to get the feeling a LOT of ECMAScript 5/later stuff is just people coming from other languages like Java implementing things that already exist, but don't exist "as object methods" -- and these guys have drunk too heavily of the "everything should be an object" kool-aid. Considering removal of other pointless/redundant polyfills.
REMOVED String.jsToCSSName Legacy function. No longer needed for anything.

4.0.0 Alpha 1, 5 May 2018 (internal)

Prototype and testing branch for the 4.x release

Cleanup of legacy cruft from ejected team members continues apace. New functionality being added too. Sufficient changes are taking place for me to say this needs a full revision number increase.

Action Regarding Description
ADDED _.make 'class' to behave as 'className' in attribute handling for XML. It's annoying how working with HTML it's "classname' but an XMLDOM such as SVG it's "class". Q: Is it possible to detect if an element is XMLDOM or HTMLDOM?
ADDED DOM-JON Namespaces ":" and name attributes "^", implemented in _.make and splitSelector
ADDED _.SVG_SUPPORTED Feature Detection (boolean) variable
ADDED DOM-JON Special Attributes BDO and IFRAME
CHANGED _.make Internal variable selector is now called dss
ADDED DOM-JON.methods Allows methods to be attached to DOM elements in a data-elementals-make-methods attribute.
ADDED Callbacks as array or named method _.node.EventAdd and DOM-JON onevent callbacks can now be passed the name of a data-elementals-make-methods method. An array containing the function or name first, followed by static parameters can also be passed.
ADDED _.Node.eachSome Handy for filtering through DOM children.
FIXED getXMLValuesByTagName major bug where limit was improperly calculated.

3.6.4 Production, 13 April 2018

Production release of 3.6.4 branch.

3.6.4 Beta, 29 March 2018 (internal)

Action Regarding Description
FIXED getXMLValuesByTagName Limit was broken/no longer implemented.
FIXED _.ajax The function/object check were BACKWARDS preventing drop-throgh. Whiskey tango foxtrot!!!
ADDED _.Event.add() forceThis parameter allows the 'this' value of a event callback to be set.
CHANGED String.splitSelector No longer returns 'div' as tag if no tagName is provided. Empty values now return an empty string instead of boolean false. This simplified the splitSelector function and makes it a hair more useful when used for something other than _.make. This also shrunk the overall code-size which is always a good thing.
FIXED _.IS_EDGE Detection routine was trying to check _.IS_IE before it was defined. Moving both out of the static declaration area -- where they were originally coded -- solved this.
FIXED _.make Routine was still using "/" instead of "~" for passing strings as selectors on the short-circuit implementation.
CHANGED DOM-JON The special content selector for option to apply content, so that the special value selector applies value.

3.6.3 Production, 15 March 2018 (public)

Minor bugfix release

oldElement.parentNode.insertBefore(newElement, oldElement.nextSibling); Thankfully null/false is treated as appendChild.
Action Regarding Description
FIXED DOM-JON 'after' Bug where appendChild was being called instead of insertBefore. No, insertAfter is NOT the answer as that doesn't even EXIST in legacy browsers! For compatibility sake you have toADDED ADDED
FIXED Event.target bug in event polyfill where event.target was not being normalized. Typo was pointing at event instead of window.

3.6.2 Production, 10 March 2018 (public)

Public release of 3.6.2 branch once documentation is completed and live.

Action Regarding Description
FIXED Website back-end But that was showing certain internal messages in the log lists. Tracked in same DB for ease of internal use, incorrect flag value was making it show up on client-side page. Will push site change with this update.

3.6.2 Beta, 7 March 2018 (Internal)

Various optimizations for size are being applied to make room for future additions whilst remaining below the 8k hard-deck for our minified gZipped target.

Action Regarding Description
FIXED Array.isArray Polyfill was checking for null on this and applied via Array.prototype. It's a static, so it would be null in most usage cases, and should have been applied in the polyfillAddStatic internal function.
CHANGED Various turned some of the static functions back into anonymous. When used via callback the overhead and performance issue is NOT as significant as most people make it out to be. Or at least not when compared to the code savings in the cases where I switched it back such as for table and list sorting. Need to analyze the regex to see if the difference is measurable there too. These are things we've all been sold as the gospel when the truth is a wee bit different.
CHANGED Polyfills pulled unneccessary else from JSON polyfill.
CHANGED _.ajax moved case 'object' before case 'function' so that the one with the return is first... pointless change but it knocked 22 bytes off the compression. Gzip is weird... though is this happening because of gz compression quirks or because "closure" handles it differently? Either way 22 bytes is 22 bytes when you have a 8k hard ceiling.
REMOVED Warnings Console warning for omitting media type on _.Load.style. The default value is not "screen,projection,tv". YES I realize HTML 5 validation complains about the latter, don't even get me STARTED how how utterly jacktarded that is... just more proof the folks working on HTML 5 were unqualified to create 4 Strict's successor!
CHANGED selector.special selector.content Use case statements instead of Array lookups for matching actions in _.make. Despite being more code it is clearer what is going on, and actually on the gzip minified version compresses smaller due to repetition. It probably executes faster too given what garbage JavaScript arrays are on performance.
FIXED DSS bug 'fast content' where textnodes were appended to IMG instead of being applied as an alt attribute!
ADDED _.make ability to pass a DOM-JON Array directly to _.make as the first parameter. All elements in the Array will be created with the function returning true.
RENAMED _.ids Used to be called _.madeCollection. Testers reported it makes more sense once the option to populate off the live DOM was added.
ADDED body[data-elementals-idParse] This optional attribute which will trigger a node walk of document.body adding any found ID's to _.ids when elementals.js is loaded.
FIXED _.Node.textContent Bug relating to ability to grab Element.tagName and case insensitivity for XML vs. SGML parsing.
FIXED Website back-end bug in website backend that disliked when properties in the reference had their names changed. Switched to doing full re-index on modify instead of partial since it's not big enough to worry about the overhead.
CHANGED Object Extensions application of both static and prototype polyfills and Object extensions from multiple calls to two functions from objects created at call-time, to a single loop of a monolithich array of objects containing ALL such polyfills. Shed code resulting in significant drop in gzipped size, and reduced "start" time in legacy IE to almost what you get in a modern browser.
FIXED Code Commenting legacy comments updated to reflect code changes. Seems minor, it isn't! Guys, if you're gonna change how sections work, update the comments next to / around it!

3.6.1 Production, 4 March 2018 (Public Release)

Live version of 3.6.1 beta 2, no significant differences

3.6.1 Beta 2, 4 March 2018 (Internal)

This versions primary objective is to optimize the code for the best gzip compression without compromising performance -- since we're butting heads with that 8k hard ceiling.

Action Regarding Description
CHANGED _.Throw.nonStringish now returns String(value) if it doesn't actually Throw, reducing code redundancies and shaving a couple bytes off the gzip compressed version.
REMOVED _.Metrics.windowWidth _.Metrics.windowHeight Since ALL they did is return document.documentElement.clientWidth and document.documentElement.clientHeight respectively.
FIXED XML vs. HTML Several sections of code using Element.tagName were written assuming XML namespace, others with HTML. Remember folks to always make tagname comparisons case insensitive if you don't know which DOCTYPE is going to be used, since that can change the case!
FIXED eProgress.js bug where the 'showProgress" class was not getting set if you called eProgress.auto as your first action.

3.6.1 Beta, 25 February 2015 (Internal)

Action Regarding Description
FIXED Array polyfills MAJOR bug in Array reduction polyfills. Routine to do both left and right reducing overall code wrapped in lockout for no reason and utterly broken referring to 'this' instead of 'arr'
ADDED _.madeCollection Object which contains any elements created with _.make that have an HTML id. The element's ID is the Object index of the element.
ADDED _.Throw.nonStringish Tests for not only that something CAN be a string, but also that it is not boolean, empty, a number, an object or function.

3.6.0 Public, 23 February 2018 (Public Release)

Action Regarding Description
REVISED _.make Uses ~ instead of / for 'special text' in selectors.
ADDED "fast text" ~ "fast text" behavior will for certain elements -- img, input, option, textarea -- be applied as src (for img) and value (for form elements) instead of as a new textNode. Just makes the shorthand even more useful.
ADDED Special Attributes more "special attributes" to _.make
FIXED internals some routines were changed to use the "internal" temp variable instead of a unique one, screwing up that some routines CALLING those routines also needed that global temp. The change made no sense anyways since their values weren't needed inside the 'internal' scope.

Note changes to _.make also impact _.write

3.6.0 Beta, 22 February 2018 (Internal)

Attempting further code-size optimizations, and fixing the 'quick text' bug in _.make. This is getting a minor revision number update to emphasize the change in _.make's functionality, as well as to distance itself from the issues that arose due to team conflicts on the 3.5 branch. When this version reaches production it will be the first to be promoted actively since the 3.1.0 update. Something ELSE I thought the folks I handed this off to could handle. Silly me!

3.5.2 PRODUCTION, 22 February 2018 (Public Relase)

Live version of 3.5.2a after testing.

3.5.2a Beta, 21 February 2018 (Internal)

Performing complete code audit after untested and unwanted changes implemented by FORMER team member. Time to put on the benevolent dictator hat.

Action Regarding Description
REVERTED _.Node.text() to original behavior of manually adding and condensing textNode.nodeValue by walking the passed element with _.Node.eachAll(). This is due to the radical differences between Element.innerText and Element.textContent. See this excellent article on the topic: http://perfectionkills.com/the-poor-misunderstood-innerText/ for more about said differences. They are not the same thing, they do NOT behave consistently cross-browser, so we are NOT going to use them!
ADDED Features _.Node.eachAllNoMask and _.Node.eachChildNoMask.
ADDED String.condense() Results in any passed text returning all whitespace reduced to a single space, as per HTML's typical behavior.
ADDED polyfill for Window.getComputedStyle
ADDED _.Node.textFormatted Returns the contnet text condensed as per HTML, but with any element nodes that create block-style behaviors having /r/n added after them. Q: Perhaps I could make this output markdown? I'm not a fan, but it could be useful.
REMOVED @ special code temporarily the @ special in _.make for anchors and script tags due to conflict between URI's and the '/' used for quick text. Best solution would be to use a different character for the quick text command, though that involves rewriting all the demo's and documentation. Was a good idea, poorly implemented.

3.5.1 Production, 21 February 2018 (Public release)

Major bugfixes due to missed typo's in code fixed. I am unsure how these got introduced, many of them being flat out nonsensical changes to the codebase from the 3.4 branch. I mean lands sake even "use strict"; was screwed up! Once again, time to purge the team?

Action Regarding Description
REVISED primary codebase codebase back to original construction of ALL properties of "underscore" declared inside the self-instancing function. This allows "use strict" to be applied only to elementals should the script be concatenated with other scripts. It was originally set up that way, FORMER team member re-arranged codebase without asking first.
FIXED naming conventions multiple variable names that were not updated to the proper 'verbose' naming format after FORMER team member shortened them all. This is all on me (Jason) since I didn't ride herd enough back in August (was needed elsewhere), nor was I as thorough as I should have been in double-checking undoing the DAMAGE.
FIXED Linting is dumb issues in codebase caused by FORMER team member relying on a 'linter' telling them that intentional codebase decisions were wrong -- when they clearly were not. Little tip folks, that bitching about the mere PRESENCE of binary operators? Yeah, screw that. If you're going to use an automated tool, at least know when what it is telling you is grade A farm fresh manure!
FIXED _.ajax complete gibberish variable assignment in AJAX routine preventing onprogress from even functioning!

3.5.1a Beta, 10 February 2018 (internal)

Error checking and minor revisions in preparation for 3.5.1 bugfix release.

Action Regarding Description
ADDED command attributes Check for "after, before, first, last, replace" that apply elements to the DOM inside _.make so that if the attribute object contains more than one each of these an error is thrown halting execution.
MODIFIED _.make ...So that the aformentioned "DOM addition" command attributes are performed after all other attributes are applied to the element. This avoids the problem of legacy IE being unable to apply certain attribute values -- such as type="" -- to an element that is already on the live DOM.

3.5 Production, 25 January 2018 (Public Release)

Production release of the 3.5 branch. Laughably more time was spent on documenting the changes than were needed on testing them.

3.5b Beta, 8 December 2017 (internal)

Action Regarding Description
ADDED _.make Attribute array functionality is now available in the content parameter of _.Node.write as the code for handling that has been moved into that function. This lets you easily/quickly add JSON build DOM structures using _.Node.write instead of having to always make at least one new parent node with _.make.
ADDED _.Metrics.windowWidth _.Metrics.windowHeight ERROR - No Comment left!!!
RENAMED _.safeString USed to be called _.normalize, renamed so as to not cause confusion with String.normalize. Special thanks to "IronWulf" for pointing that out.

3.5a Beta, 24 November 2017 (internal)

Action Regarding Description
ADDED _.make passage of String in additon to array
ADDED Number.isInteger polyfill for non-standard but damned useful method
ADDED String.SAFE_STRING_LIMIT Just seems handy.

View older entries here

Advertisement