1.7.1 • Published 5 years ago

oop-node v1.7.1

Weekly downloads
2
License
ISC
Repository
github
Last release
5 years ago

oop-node

OOP模式的结构化节点

安装

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>

使用

代码

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());

输出

<view class="user-name" date="2019-04-07"><!-- User Name -->Marvin<!-- User Name End --></view>

带缩进

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

输出

<view class="user-name" date="2019-04-07">
    <!-- User Name -->
    Marvin
    <!-- User Name End -->
</view>
1.7.1

5 years ago

1.7.0

5 years ago

1.6.4

5 years ago

1.6.3

5 years ago

1.6.2

5 years ago

1.6.1

5 years ago

1.6.0

5 years ago

1.5.1

5 years ago

1.5.0

5 years ago

1.4.13

5 years ago

1.4.11

5 years ago

1.4.10

5 years ago

1.4.9

5 years ago

1.4.8

5 years ago

1.4.7

5 years ago

1.4.6

5 years ago

1.4.5

5 years ago

1.4.4

5 years ago

1.4.3

5 years ago

1.4.2

5 years ago

1.3.12

5 years ago

1.3.11

5 years ago

1.3.7

5 years ago

1.3.4

5 years ago

1.3.3

5 years ago

1.3.2

5 years ago

1.3.0

5 years ago

1.2.0

5 years ago

1.0.5

5 years ago

1.0.0

5 years ago