(element)
| 142 | } |
| 143 | |
| 144 | appendBlockForElement(element) { |
| 145 | const elementIsBlockElement = this.isBlockElement(element) |
| 146 | const currentBlockContainsElement = elementContainsNode(this.currentBlockElement, element) |
| 147 | |
| 148 | if (elementIsBlockElement && !this.isBlockElement(element.firstChild)) { |
| 149 | if (!this.isInsignificantTextNode(element.firstChild) || !this.isBlockElement(element.firstElementChild)) { |
| 150 | const attributes = this.getBlockAttributes(element) |
| 151 | const htmlAttributes = this.getBlockHTMLAttributes(element) |
| 152 | if (element.firstChild) { |
| 153 | if (!(currentBlockContainsElement && arraysAreEqual(attributes, this.currentBlock.attributes))) { |
| 154 | this.currentBlock = this.appendBlockForAttributesWithElement(attributes, element, htmlAttributes) |
| 155 | this.currentBlockElement = element |
| 156 | } else { |
| 157 | return this.appendStringWithAttributes("\n") |
| 158 | } |
| 159 | } |
| 160 | } |
| 161 | } else if (this.currentBlockElement && !currentBlockContainsElement && !elementIsBlockElement) { |
| 162 | const parentBlockElement = this.findParentBlockElement(element) |
| 163 | if (parentBlockElement) { |
| 164 | return this.appendBlockForElement(parentBlockElement) |
| 165 | } else { |
| 166 | this.currentBlock = this.appendEmptyBlock() |
| 167 | this.currentBlockElement = null |
| 168 | } |
| 169 | } |
| 170 | } |
| 171 | |
| 172 | findParentBlockElement(element) { |
| 173 | let { parentElement } = element |
no test coverage detected