Giter Site home page Giter Site logo

bbmoz / inject-decorator Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 127 KB

Create decorators that can inject anything into your JS modules!

Home Page: https://git.io/vSK8Z

License: MIT License

JavaScript 93.80% HTML 6.20%
inject dom babel es2016 es7 annotation decorator

inject-decorator's Introduction

Inject Decorator

npm version Build Status

Create decorators that can inject anything into your JS modules!

Example using DOM elements

Define an object that represents some dom elements, call the library with it, and then use it to decorate a class as shown below. Elements are attached to $ of the class.

// part 1
import inject from 'inject-decorator'

const domElements = {
  heading: document.getElementById('heading'),
  footer: document.querySelector('footer')
}

export default inject(domElements)
// part 2
import dom from './dom'

@dom('heading')
class Hello {
    constructor (text) {
        this.$heading = Hello.$.heading
        this._displayDomElements(text)
    }

    _displayDomElements (text) {
        this.$heading.innerHTML = text
        this.$heading.style = 'display: block'
    }
}

To inject more elements than just heading, simply comma delimit i.e. @dom('heading', 'footer'). Or if you want access to all elements, use @dom without any arguments.

inject-decorator's People

Contributors

bbmoz avatar greenkeeper[bot] avatar

Watchers

 avatar  avatar

inject-decorator's Issues

An in-range update of babel-preset-env is breaking the build 🚨

Version 1.6.0 of babel-preset-env just got published.

Branch Build failing 🚨
Dependency babel-preset-env
Current Version 1.5.2
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As babel-preset-env is β€œonly” a devDependency of this project it might not break production or downstream projects, but β€œonly” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this πŸ’ͺ

Status Details
  • βœ… dependency-ci Dependencies checked Details
  • ❌ continuous-integration/travis-ci/push The Travis CI build could not complete due to an error Details

Release Notes v1.6.0

v1.6.0 (2017-07-04)

πŸš€ New Feature

We updated our mappings to support native trailing function commas and string paddings in Node.js 8+.

πŸ› Bug Fix

We added support for using browserslist's chromeandroid in targets.

πŸ“ Documentation

Thanks to @graingert and @pfiaux for pointing out some needed updates to the uglify-js-related docs.

Commits

The new version differs by 10 commits.

  • 8d09fa5 1.6.0
  • 6e06755 Update changelog
  • 9e3f5e8 Update yarn.lock
  • 0da8e7b Tweak uglify option docs (#368)
  • f5ee86f Merge pull request #367 from babel/chromeandroid
  • 9eb6b3b add test
  • 3c841bf Handle chromeandroid browserslist value.
  • fd11bb3 Bump compat-table for node8 support (#363)
  • d1b05fa add probot-stale [skip ci] (#353)
  • 240456f Update changelog for v1.5.2 [skip ci]

See the full diff

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.