An open API service indexing awesome lists of open source software.

https://github.com/stagas/with-properties

custom elements base class factory with properties mapped to observed attributes
https://github.com/stagas/with-properties

custom-elements mixin observed-attributes properties web-components

Last synced: 9 days ago
JSON representation

custom elements base class factory with properties mapped to observed attributes

Awesome Lists containing this project

README

          

with-properties


custom elements base class factory with properties mapped to observed attributes


🔧 Install
· 🧩 Example
· 📜 API docs
· 🔥 Releases
· 💪🏼 Contribute
· 🖐️ Help

***

## Install

```sh
$ npm i with-properties
```

## API

#### Table of Contents

* [withProperties](#withproperties)
* [Parameters](#parameters)

### withProperties

[src/index.ts:84-129](https://github.com/stagas/with-properties/blob/347859f1dd6689f28f04586900fbe4e8a754a482/src/index.ts#L84-L129 "Source code on GitHub")

```js
class Foo extends withProperties(
HTMLElement,
class {
string? = String
number? = Number
boolean = Boolean
implicitString = 'string'
implicitNumber = 123
implicitBoolean = true
somethingElse? = new Uint8Array(1)
}
) {}
```

#### Parameters

* `parent` **C** The parent constructor to extend (usually `HTMLElement`)
* `propsClass` **[Constructor](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/constructor)\

** A "props" class to create the properties from

Returns **any** A base constructor to be extended from

## Contribute

[Fork](https://github.com/stagas/with-properties/fork) or
[edit](https://github.dev/stagas/with-properties) and submit a PR.

All contributions are welcome!

## License

MIT © 2021
[stagas](https://github.com/stagas)