# oop-node

> An element-struct based OOP

Latest version **1.7.1** (published 2019-09-17) · ISC license · 0 weekly downloads

## Install

```sh
npm install oop-node
pnpm add oop-node
yarn add oop-node
bun add oop-node
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.7.1 |
| Published | 2019-09-17 |
| First published | 2019-04-06 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 25.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | imnull@outlook.com |
| Maintainers | imnull |
| Keywords | element, oop, javascript |

## Links

- npm: https://www.npmjs.com/package/oop-node
- Repository: https://github.com/imnull/oop-node
- Homepage: https://github.com/imnull/oop-node#readme
- Issues: https://github.com/imnull/oop-node/issues
- npm.io page: https://npm.io/package/oop-node

## Recent versions

- 1.7.1 (latest) — 2019-09-17
- 1.7.0 — 2019-09-09
- 1.6.4 — 2019-09-06
- 1.6.3 — 2019-09-06
- 1.6.2 — 2019-09-05
- 1.6.1 — 2019-09-05
- 1.6.0 — 2019-09-04
- 1.5.1 — 2019-07-22
- 1.5.0 — 2019-07-22
- 1.4.13 — 2019-07-10
- 1.4.11 — 2019-07-10
- 1.4.10 — 2019-07-10
- 1.4.9 — 2019-06-29
- 1.4.8 — 2019-06-03
- 1.4.7 — 2019-06-03
- … 15 more at https://npm.io/package/oop-node/versions

## README

# oop-node
OOP模式的结构化节点

## 安装

```bash
npm i oop-node
```

## 继承结构

```
BaseNode
    - NamedNode
        - Attribute
        - ElementAbstract
            - ElementBase
                + AttributeList :: attributes
                - ElementComment
                - ElementText
                - Element
                    + NodeList<ElementAbstract> :: childNodes
        - Document
            + NodeList<ElementAbstract> :: childNodes
    - TreeNode
BaseList
    - TypedList<T>
        - NodeList<T>
            - AttributeList<Attribute>
```

## 使用

### 代码
```js
const { Document } = require('oop-element');

let document = new Document();
let div = doc.appendChild(doc.createElement('view'));
div.setAttribute('class', 'user-name').setAttribute('date', '2019-04-07');
div.appendChild(doc.createComment('User Name'));
div.appendChild(doc.createElement('h1')).appendChild(doc.createText('Hello~'));
div.appendChild(doc.createText('Marvin'));
div.appendChild(doc.createElement('image')).setAttribute('src', 'http://asdfsadfsa.asfdfa.com');
div.appendChild(doc.createComment('User Name End'));
console.log(doc.toString());
```

### 输出
```html
<view class="user-name" date="2019-04-07"><!-- User Name -->Marvin<!-- User Name End --></view>
```

### 带缩进
```js
let document = new Document({
    format: true,   // 带格式
    indent: '    ', // 缩进字符串（默认2空格）
});

```

### 输出
```html
<view class="user-name" date="2019-04-07">
    <!-- User Name -->
    Marvin
    <!-- User Name End -->
</view>
```

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