(
meta: MetaDefinition,
forceCreation: boolean = false,
)
| 153 | } |
| 154 | |
| 155 | private _getOrCreateElement( |
| 156 | meta: MetaDefinition, |
| 157 | forceCreation: boolean = false, |
| 158 | ): HTMLMetaElement { |
| 159 | if (!forceCreation) { |
| 160 | const selector: string = parseSelector(meta); |
| 161 | // It's allowed to have multiple elements with the same name so it's not enough to |
| 162 | // just check that element with the same name already present on the page. We also need to |
| 163 | // check if element has tag attributes |
| 164 | const elem = this.getTags(selector).filter((elem) => containsAttributes(meta, elem))[0]; |
| 165 | if (elem !== undefined) return elem; |
| 166 | } |
| 167 | const element: HTMLMetaElement = this._dom.createElement('meta') as HTMLMetaElement; |
| 168 | setMetaElementAttributes(meta, element); |
| 169 | const head = this._doc.getElementsByTagName('head')[0]; |
| 170 | head.appendChild(element); |
| 171 | return element; |
| 172 | } |
| 173 | } |
| 174 | |
| 175 | function buildMetaSelector(attrSelector: string): string { |
no test coverage detected