0.0.6 • Published 5 years ago

html5-setattribute-extended v0.0.6

Weekly downloads
1
License
MIT
Repository
-
Last release
5 years ago

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

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago