New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

als-component

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

als-component

Managing elements and states.

  • 0.1.0
  • npm
  • Socket score

Version published
Weekly downloads
13
decreased by-31.58%
Maintainers
1
Weekly downloads
 
Created
Source

als-component being tested not for use

Frontend

To show colored html code inside string, use es6-string-html plugin for Vscode.

Example:

<!-- Add Component class -->
   <script src="/component.js"></script>
<!-- Add Initial element with component name and input for changing state -->
   <input id="input" type="text" oninput="test.state.name=this.value; test.update()">
   <div component="test"></div>

<script>
   let test = new Component(
      'test', // component name
      function() { //function for generating component's html
         return /*html*/`<div component="test">
            Hello ${this.state.name}
         </div>`
      },
      {name:'Alex'}, // initial state
      {update:[ // hooks object with update hook
         function(state,init) {
            if(init) document.getElementById('input').value = state.name
         }
      ]}
   )
// find element [component=test] and update it 
   test.update()
</script>

Syntax:

let component = new Component(name,component,state = {},hooks={update:[],remove:[],add:[]})
component.fn // component function
component.state // component state
component.hooks // component hooks

Exceptions for component name: state,import,export,convert,script.

Component inside component

<ul component="todos"></ul>
<script>
   let todos = [{id:1,name:'do something'},{id:2,name:'do else'}]

// todo component
   let todoComponent = new Component('todo',function({name,id}) {
      return /*html*/`<li component="todo" id="${id}">${name}</li>`
   })

// todos component
   let todosComponent = new Component('todos',function() {
      return /*html*/`
      <ul component="todos">
         ${this.state.todos.map(todo => todoComponent.fn(todo)).join('')}   
      </ul>`
   },{todos})

   todosComponent.update()
</script>

Actions

remove,apdate, add, addBefore, addAfter

Hooks

remove,apdate, add init

component.state
Component.state - Combine states

Node.js

import
export

FAQs

Package last updated on 24 Apr 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc