Beta API Can Change
Jenie
A small but mighty web components framework/library.
1.5 Breaking Changes
- Jenie.module replaced with loader and es6 module support
 
1.4 Breaking Changes
- Jenie.router.route.componentUrl changed to Jenie.router.route.load
 - Jenie.router.contain removed and changed to Jenie.router.container
 - Jenie.router.external no longer converts to RegExp
 - removed Jenie.component.template as comment.
 - j-on binder events have been moved from Jenie.controller.model to Jenie.controller.events.
 
Support
- IE10~
 - IE11
 - Chrome
 - Firefox
 - Safari 7
 - Mobile Safari
 - Chrome Android
 
Install
npm install jenie --save- UMD 
dist/jenie.min.js - UMD with Web Component Pollyfill 
dist/jenie.polly.min.js - Web Component Pollyfill 
dist/webcomponents-lite.min.js 
Example
    Jenie.component({
        name: 'v-home',
        template: `
            <h1 j-text="title"></h1>
        `,
        model: {
            title: 'Old Title'
        },
        created: function () {
            this.model.title = 'New Title';
        }
    });Jenie.setup({
    http: {
        request: function (opt, xhr) {
            return true; // false will cancel the http.fetch
        },
        response: function (opt, xhr) {
            return true; // false will cancel the http.fetch handlers
        }
    },
    loader: {
        esm: true, // Enables ES6 import export module support
        loads: [
            {
                file: '/components/c-menu.js',
                execute: true // Since this component is not a module/route or imported we must execute.
            }
        ]
    },
    router: {
        routes: [
            {
                path: '/',
                title: 'Home',
                component: 'v-home',
                file: 'views/v-home.js'
            }
        ]
    }
});<html>
<head>
    <base href="/">
    <script src="jenie.min.js" defer></script>
    <script src="index.js" defer></script>
</head>
<body>
    <j-view></j-view>
</body>
</html>API
Jenie.component(options)
Returns a new Jenie web component and defines/registers a custom web component.
options: Objectname: StringRequired the tag namefile: Stringpath to JS component script.template: Element, String, QueryRequiredmodel: Object<Any>See Jenie.controller.modelevents: Object<Function>See Jenie.controller.eventsmodifiers: Object<Function>See Jenie.controller.modifierscreated: FunctionTriggered once on creation.attached: FunctionTriggered on each DOM attachment.detached: FunctionTriggered on each DOM detachment.attributed: FunctionTriggered attribute change.
Jenie.setup(options)
The recommend entry point. This allows you to setup Jenie and automatically starts the router
options: Objecthttp: ObjectJenie.http options.loader: ObjectJenie.loader options.router: ObjectJenie.router options.
Jenie.router
options: Objecthash: BooleanHash URL mode. Default is false.trailing: BooleanTrailing slash. Default is false.external: String, RegExp, FunctionFilters URL requests. If true or match Router will not handle request.container: ElementSets the event listeners for HREFs to the container. Default is window. Jenie use event delegation.routes: Arrayroute: Objecttitle: StringThe title for the page.component: StringThe name of a component.file: Object, StringPath or Jenie.loader.load Object to a web component JS file.path: StringAny path.parameters: StringNamed â/account/{user}â, or catchalls â{*}â,
run: FunctionMust be called after is createdredirect: FunctionUses window.location.href which is treated like a 301 redirect for SEO.add: Functionpath: String
remove: Functionpath: String
get: Functionpath: StringExact path matching, route path variables are not taken into account.
find: FunctionApproximate path matching, route path variables are taken into account.path: String
navigate: FunctionChanges to a new page.path: StringPath to navigate.
on: EventEmitternavigated: Event
Jenie.loader
ES6 import and export module support. Imports must be absolute from the domain. Also export default is the only export format supported. Please do not use Loader.interpret to handle user input.
options: Objectesm: Booleanenable es6 module support for scripts.loads: Array<Object, String>Adds load objects or strings such as non route components.load: Object, Stringfile: StringPath to a web component JS file.execute: BooleanEnable this to load and define/register custom components.esm: BooleanSimilar to Jenie.loader.options this enables es6 module support but on an individual bases.
Jenie.http
options: Objectrequest: FunctionIntercepts the request. If the return value is false the fetch will not be triggered.options: Objectxhr: Object
response: FunctionIntercepts the request. If the return value is false the fetch success and error will not be triggered.options: Objectxhr: Object
mime: Objectserialize: Functionfetch: FunctionA fetch request.options: Objectaction: StringResource action url. Requiredsuccess: FunctionRequired The fetch response.error: FunctionRequired The fetch response.method: StringValid methods get, post, put, deletedata: ObjectIf method isGETthan data is concatenated to theaction/urlas parameters.requestType: StringConverts the request data before sending.scriptâtext/javascript, application/javascript, application/x-javascriptâjsonâapplication/jsonâ stringifyoptions.dataxmlâapplication/xml, text/xmlâhtmlâtext/htmlâtextâtext/plainâ- DEFAULT âapplication/x-www-form-urlencodedâ serialized 
options.data 
responseType: StringConverts the response data after sending.scriptâtext/javascript, application/javascript, application/x-javascriptâjsonâapplication/jsonâxmlâapplication/xml, text/xmlâhtmlâtext/htmlâtextâtext/plainâ
contentType: StringShort hand to set the Content-Type Headers. (For request)accept: StringShort hand to set the Accept Headers. (For response)mimeType: StringOverwrites return type.username: Stringpassword: StringwithCredentials: Booleanheaders: ObjectA low level headers object it will map directly to the XHR header. The Will overwrite any above options.
Jenie.controller(options, callback)
Returns an instance of a new controller.
options: Objectnameviewevents: Object<Function>j-on-[event name]= bindermodifiers: Object<Function>j-[*]=â* | modifier nameâmodelCopies the provided and observes itâs properties. Setting a property toundefinedwill delete or splice itâs self.ArrayObject to be observed.spliceTriggers the callback.pushTriggers the callback.shiftTriggers the callback.popTriggers the callback.unshiftTriggers the callback.
ObjectObject to be observed.$removeFunction attached deep removes/deletes a property and triggers the callback.$setFunction attached deeply sets or adds a new property to be observed triggers the callback.
FunctionAsync return of the model. Argument providedresolve(Object: model).
callback: Function
Jenie.global
A global object for you.
Jenie.query(String: querySelector)
The result of a querySelector in the current document document.currentScript.ownerDocument.querySelector()
- Returns: 
document.currentScript.ownerDocument.querySelector() 
Jenie.script()
- Returns: 
document.currentScript 
Jenie.document()
- Returns: 
document.currentScript.ownerDocument 
Authors
Alexander Elias - AlexanderElias
License
This project is licensed under the MPL-2.0 License - LICENSE.md Why You Should Cheose MPL-2.0