tmpvar / weld

Template antimatter for Node.js (Browsers too!)
674 stars 39 forks source link

Feature insert precheck #49

Open ridencww opened 8 years ago

ridencww commented 8 years ago

Added a couple of unit tests for wtfaremyinitials' attribute setter change. Also added another hook, insertPrecheck along with tests for same.

I have encountered two use cases that require the ability to skip insertion or to modify an element prior to insertion. This can be accomplished by overriding the insertPrecheck function and returning true to insert and false to not insert. If you don't override insertPrecheck, the default implementation in weld.js returns true (insert element). While this functionality could have been accomplished by overriding insert, I felt it less error prone to add another hook with a boolean return instead of having to override the insert function and duplicating the insert code.