html5-setattribute-extended

0.0.6 • Public • Published

vue setattribute-extended

Enable special characters in Vue attribute names.

ele.setAttribute( '@example', 'foo')

(Extension designed to work with any JS framework.)

Explanation

setattribute-extended is a JavaScript monkey patch that allows the DOM setAttribute† function to correctly create "extended" attribute names. (e.g. &click) Without it, extended characters cannot be set in attribute names. Attribute names (by default) are limited to
RegExp ``` /^[a-z0-9-_:.]+$/i


There is a cost.  Extended names 
are slower to set than plain names... 
(the code uses three DOM level 1 methods). Therefore,  the slower, extended algorithm is
applied only to names with special characters</u>.

&dagger; The original function is still available as ```_setAttribute( )```
## Usage

npm install --save vue-setattribute-extended

Just load the script and **setAttribute** is extended thereafter.

import 'vue-setattribute-extended'


The browser's, (and hence Vue's), <b>setAttribute</b> method will be monkey-patched the instant main.js is loaded into the browser.  The patch is transparent to any application/DOM usage, as well as for Vue. 

This extended setAttribute code patch will persist <u>throughout the duration of your app's execution;</u> and the browser will simply discard it when the next page is loaded.  



## test

cd test open test.html

// setAttributeExtended passes 4 tests OK

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i html5-setattribute-extended

      Weekly Downloads

      0

      Version

      0.0.6

      License

      MIT

      Unpacked Size

      4.59 kB

      Total Files

      4

      Last publish

      Collaborators

      • genedronek