|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
611 bytes
|
| Line | |
|---|
| 1 | 'use strict'
|
|---|
| 2 |
|
|---|
| 3 | const implementation = {
|
|---|
| 4 | isTag: node => node !== undefined && 'name' in node,
|
|---|
| 5 | getAttributeValue: ( elem, name ) => {
|
|---|
| 6 | if( implementation.isTag( elem ) && elem.attribs ) return elem.attribs[ name ]
|
|---|
| 7 | },
|
|---|
| 8 | getChildren: node => node.children,
|
|---|
| 9 | getName: elem => {
|
|---|
| 10 | if( implementation.isTag( elem ) ) return elem.name
|
|---|
| 11 | },
|
|---|
| 12 | getParent: node => node.parent,
|
|---|
| 13 | getText: node => node.children.map( child => {
|
|---|
| 14 | if( child.text ) return child.text
|
|---|
| 15 |
|
|---|
| 16 | if( implementation.isTag( child ) ) return implementation.getText( child )
|
|---|
| 17 |
|
|---|
| 18 | return ''
|
|---|
| 19 | }).join( '' )
|
|---|
| 20 | }
|
|---|
| 21 |
|
|---|
| 22 | module.exports = implementation
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.