# hyperhtml-comp

> Some hyperHTML.Component helper

Latest version **0.1.3** (published 2017-09-26) · ISC license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install hyperhtml-comp
pnpm add hyperhtml-comp
yarn add hyperhtml-comp
bun add hyperhtml-comp
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.1.3 |
| Published | 2017-09-26 |
| First published | 2017-09-25 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Andrea Giammarchi |
| Maintainers | webreflection |
| Keywords | hyperhtml, component, connect, disconnect, helpers |

## Links

- npm: https://www.npmjs.com/package/hyperhtml-comp
- Repository: https://github.com/WebReflection/hyperhtml-comp
- Homepage: https://github.com/WebReflection/hyperhtml-comp#readme
- Issues: https://github.com/WebReflection/hyperhtml-comp/issues
- npm.io page: https://npm.io/package/hyperhtml-comp

## Alternatives

- [@tsparticles/shape-image](https://npm.io/package/@tsparticles/shape-image.md) — 303.7K weekly downloads
- [@tsparticles/shape-line](https://npm.io/package/@tsparticles/shape-line.md) — 233.7K weekly downloads
- [stringify-attributes](https://npm.io/package/stringify-attributes.md) — 58.6K weekly downloads
- [mobile-drag-drop](https://npm.io/package/mobile-drag-drop.md) — 46.3K weekly downloads
- [@comunica/actor-rdf-parse-html](https://npm.io/package/@comunica/actor-rdf-parse-html.md) — 29.2K weekly downloads

## Recent versions

- 0.1.3 (latest) — 2017-09-26
- 0.1.2 — 2017-09-25
- 0.1.1 — 2017-09-25
- 0.1.0 — 2017-09-25
- 0.0.0 — 2017-09-25

## README

# hyperhtml-comp

[![License: ISC](https://img.shields.io/badge/License-ISC-yellow.svg)](https://opensource.org/licenses/ISC) [![donate](https://img.shields.io/badge/$-donate-ff69b4.svg?maxAge=2592000&style=flat)](https://github.com/WebReflection/donate)

- - -

This script provides `connected` and `disconnected` callback capabilities for [hyperHTML](https://github.com/WebReflection/hyperHTML) components.

You can include it either as module or as external script.

```html
<script src="https://unpkg.com/hyperhtml-comp@latest/min.js"></script>
```

Please note this helper does not depend on _hyperHTML_ so you can add it at runtime once or in any part of your page.


### Example
```js
import {Component} from 'hyperhtml';

class Clock extends Component {

  update() {
    this.time = (new Date).toLocaleTimeString();
    this.render();
  }

  // equivalent of Custom Elements connectedCallback
  onconnected() {
    console.log('start time');
    this.update();
    this.timer = setInterval(() => this.update(), 1000);
  }

  // equivalent of Custom Elements disconnectedCallback
  ondisconnected() {
    console.log('end time');
    clearInterval(this.timer);
  }

  render() { return this.html`
    <p
      onconnected=${this}
      ondisconnected=${this}
    >
      ${this.time}
    </p>`;
  }
}

hyperHTML(document.body)`${new Clock}`;
```

### Compatibility

IE9+ (once transpiled) and every other Mobile / Desktop browser.

ES2015 compatible browsers can test the [live example](https://webreflection.github.io/hyperhtml-comp/test/),
while every old/new browser can [test raw functionality here](https://webreflection.github.io/hyperhtml-comp/test/raw/).

---
_Source: https://npm.io/package/hyperhtml-comp · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
