How to use domexception - 3 common examples

To help you get started, we’ve selected a few domexception examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jsdom / jsdom / lib / jsdom / living / nodes / HTMLFrameElement-impl.js View on Github external
}
        contentDoc.contentType = contentType.essence;
      }
    }

    const encoding = sniffHTMLEncoding(data, sniffOptions);
    contentDoc._encoding = encoding;

    const html = whatwgEncoding.decode(data, contentDoc._encoding);

    try {
      parseIntoDocument(html, contentDoc);
    } catch (error) {
      if (
        error.constructor.name === "DOMException" &&
        error.code === DOMException.SYNTAX_ERR &&
        contentDoc._parsingMode === "xml"
      ) {
        // As defined (https://html.spec.whatwg.org/#read-xml) parsing error in XML document may be reported inline by
        // mutating the document.
        const element = contentDoc.createElementNS("http://www.mozilla.org/newlayout/xml/parsererror.xml", "parsererror");
        element.textContent = error.message;

        while (contentDoc.childNodes.length > 0) {
          contentDoc.removeChild(contentDoc.lastChild);
        }
        contentDoc.appendChild(element);
      } else {
        throw error;
      }
    }
github facebookarchive / atom-ide-ui / modules / nuclide-commons / observable.js View on Github external
export function toAbortablePromise(
  observable: Observable,
  signal?: ?AbortSignal,
): Promise {
  if (signal == null) {
    return observable.toPromise();
  }
  if (signal.aborted) {
    return Promise.reject(DOMException('Aborted', 'AbortError'));
  }
  return observable
    .race(
      Observable.fromEvent(signal, 'abort').map(() => {
        throw new DOMException('Aborted', 'AbortError');
      }),
    )
    .toPromise();
}
github facebookarchive / atom-ide-ui / modules / nuclide-commons / observable.js View on Github external
Observable.fromEvent(signal, 'abort').map(() => {
        throw new DOMException('Aborted', 'AbortError');
      }),
    )

domexception

An implementation of the DOMException class from browsers

MIT
Latest version published 3 years ago

Package Health Score

52 / 100
Full package analysis

Popular domexception functions