Completed
Push — master ( 68e15a...5a472b )
by Michael
03:04
created

script/AbstractNodeView.js   A

Size

Lines of Code 1

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 1
rs 10
c 0
b 0
f 0
noi 1
1
class AbstractNodeView {
2
    constructor(node, view, getPos) {
3
        this.node = node;
4
        this.outerView = view;
5
        this.getPos = getPos;
6
7
        this.renderNode(node.attrs);
8
    }
9
10
    renderNode(attrs) {
11
        console.log(this.node, attrs);
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
12
        throw Error('renderNode must be implemented by child class!');
13
    }
14
15
    static unsetPrefixAttributes($prefix, attributes) {
16
        const cleanedAttributes = {};
17
        Object.keys(attributes).forEach((attr) => {
18
            if (attr.substr(0, $prefix.length) !== $prefix) {
19
                cleanedAttributes[attr] = attributes[attr];
20
            }
21
        });
22
        return cleanedAttributes;
23
    }
24
}
25
26
exports.AbstractNodeView = AbstractNodeView;
27