How to use the hyperview/src/services.getFirstTag function in hyperview

To help you get started, we’ve selected a few hyperview 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 Instawork / hyperview / src / index.js View on Github external
.then((responseText) => {
        if (typeof this.props.onParseBefore === 'function') {
          this.props.onParseBefore(url);
        }
        let doc = this.parser.parseFromString(responseText);
        let error = false;
        const stylesheets = Stylesheets.createStylesheets(doc);
        this.navigation.setRouteKey(url, routeKey);

        // Make sure the XML has the required elements: , , .
        const docElement = getFirstTag(doc, 'doc');
        if (!docElement) {
          console.error(`No  tag found in the response from ${url}.`);
          doc = null;
          error = true;
        } else {
          const screenElement = getFirstTag(docElement, 'screen');
          if (!screenElement) {
            console.error(`No  tag found in the  tag from ${url}.`);
            doc = null;
            error = true;
          } else {
            const bodyElement = getFirstTag(screenElement, 'body');
            if (!bodyElement) {
              console.error(`No  tag found in the  tag from ${url}.`);
              doc = null;
              error = true;
github Instawork / hyperview / src / index.js View on Github external
this.navigation.setRouteKey(url, routeKey);

        // Make sure the XML has the required elements: , , .
        const docElement = getFirstTag(doc, 'doc');
        if (!docElement) {
          console.error(`No  tag found in the response from ${url}.`);
          doc = null;
          error = true;
        } else {
          const screenElement = getFirstTag(docElement, 'screen');
          if (!screenElement) {
            console.error(`No  tag found in the  tag from ${url}.`);
            doc = null;
            error = true;
          } else {
            const bodyElement = getFirstTag(screenElement, 'body');
            if (!bodyElement) {
              console.error(`No  tag found in the  tag from ${url}.`);
              doc = null;
              error = true;
            }
          }
        }

        this.setState({
          doc,
          styles: stylesheets,
          error,
        });
        if (typeof this.props.onParseAfter === 'function') {
          this.props.onParseAfter(url);
        }
github Instawork / hyperview / src / index.js View on Github external
if (typeof this.props.onParseBefore === 'function') {
          this.props.onParseBefore(url);
        }
        let doc = this.parser.parseFromString(responseText);
        let error = false;
        const stylesheets = Stylesheets.createStylesheets(doc);
        this.navigation.setRouteKey(url, routeKey);

        // Make sure the XML has the required elements: , , .
        const docElement = getFirstTag(doc, 'doc');
        if (!docElement) {
          console.error(`No  tag found in the response from ${url}.`);
          doc = null;
          error = true;
        } else {
          const screenElement = getFirstTag(docElement, 'screen');
          if (!screenElement) {
            console.error(`No  tag found in the  tag from ${url}.`);
            doc = null;
            error = true;
          } else {
            const bodyElement = getFirstTag(screenElement, 'body');
            if (!bodyElement) {
              console.error(`No  tag found in the  tag from ${url}.`);
              doc = null;
              error = true;
            }
          }
        }

        this.setState({
          doc,
github Instawork / hyperview / src / services / stylesheets / index.js View on Github external
function createStylesheet(
  document: Document,
  modifiers = {},
): StyleSheetType<*> {
  const styles = getFirstTag(document, 'styles');
  const stylesheet = {};
  if (styles) {
    const styleElements = styles.getElementsByTagNameNS(
      Namespaces.HYPERVIEW,
      'style',
    );

    for (let i = 0; i < styleElements.length; i += 1) {
      const styleElement = styleElements.item(i);
      const hasModifier =
        styleElement.parentNode &&
        styleElement.parentNode.tagName === 'modifier';

      let styleId = styleElement.getAttribute('id');
      if (hasModifier) {
        // TODO(adam): Use less hacky way to get id of parent style element.
github Instawork / hyperview / storybook / helpers.js View on Github external
return (templateName: string, render: any) => {
    const templatePath = `${componentPath}/stories/${templateName}.xml`;
    const storyName = humps.pascalize(templateName);
    const parser = new DOMParser();
    const document = parser.parseFromString(templates[templatePath]);
    const element = getFirstTag(document, Component.localName);
    const stylesheets = Stylesheets.createStylesheets(document);
    s.add(storyName, () => render({ element, stylesheets }));
  };
};