New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

reacton-loader

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

reacton-loader

Loader for single-file Reacton components in Webpack

npmnpm
Version
2.2.18
Version published
Weekly downloads
3
Maintainers
1
Weekly downloads
 
Created
Source

reacton-loader

Loader for single-file Reacton components in Webpack

- Added example Webpack build for routes:

<my-menu>
  <nav #nav>
    <a href="/">Home</a>
    <a href="/about">About</a>
    <a href="/contacts">Contacts</a>
    <a href="/john/32">John</a>
    <a href="/john?age=32">Age</a>
  </nav>

  <script>
    import { myRoute } from '../Routes'

    exports = class {
      static connected() {
        // add a "click" event handler to the NAV element
        this.$refs.nav.addEventListener('click', event => {
          // cancel clicking on the link
          event.preventDefault()

          // trigger a link address event on myRoute element
          this.$route(myRoute, event.target.href)
        })
      }
    }
  </script>
</my-menu>

- Added example Webpack build for events:

<my-component>
  <button #reverse>Reverse array</button>
  <button #new>New array</button>
  <button #clear>Clear array</button>

  <script>
    import { myEvent } from '../Events'

    exports = class {
      static connected() {
        // add a "click" event handler for the button
        this.$refs.reverse.addEventListener('click', () => {
          // trigger "reverse" event on element myEvent
          this.$event(myEvent, 'reverse')
        })

        // add a "click" event handler for the button
        this.$refs.new.addEventListener('click', () => {
          // trigger "new-colors" event on element myEvent
          this.$event(myEvent, 'new-colors', {
            // pass a new array to the event handler
            detail: ['blue', 'orange', 'purple', 'gold']
          })
        })

        // add a "click" event handler for the button
        this.$refs.clear.addEventListener('click', () => {
          // trigger "clear-colors" event on element myEvent
          this.$event(myEvent, 'clear-colors')
        })
      }
    }
  </script>
</my-component>

Install

npm i reacton-loader -D

A fragment of the working project is shown below:

webpack.config.js

module: {
  rules: [
    {
      test: /\.htm$/,
      loader: 'reacton-loader',
    },
    ... // other rules
  ]
},

Mixins.js

export default class {
  getStringInUpperCase(str) {
    return str.toLocaleUpperCase()
  }
}

MyComponent.htm

<my-component>
  <h1>Hello, {{ getStringInUpperCase(message) }}!</h1>
        
  <style>
    h1 {
      color: {{ color }};
    }
  </style>

  <script>
    import Mixins from '../Mixins'

    exports = class extends Mixins {
      constructor(props) {
        super()
        this.message = 'Reacton'
        this.color = props.color
      }

      static mode = 'open' // add Shadow DOM
    }
  </script>
</my-component>

Keywords

framework

FAQs

Package last updated on 14 Oct 2023

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