Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code in script block may break output #129

Open
07akioni opened this issue May 11, 2021 · 3 comments
Open

Code in script block may break output #129

07akioni opened this issue May 11, 2021 · 3 comments

Comments

@07akioni
Copy link

Input:

<div>
  <script>
    console.log('</')
  </script>
</div>

Output:

[
  {
    "type": "element",
    "tagName": "div",
    "attributes": [],
    "children": [
      {
        "type": "text",
        "content": "\n  "
      },
      {
        "type": "element",
        "tagName": "script",
        "attributes": [],
        "children": [
          {
            "type": "text",
            "content": "\n    console.log('"
          },
          {
            "type": "attribute",
            "content": "<"
          },
          {
            "type": "tag-end"
          },
          {
            "type": "text",
            "content": "cript>\n"
          }
        ]
      }
    ]
  }
]
@andrejewski
Copy link
Owner

Hmm; this ought to be fixed, it should work as you expect and has some special handling already: https://github.com/andrejewski/himalaya/blob/master/src/tags.js#L5

@07akioni are you interested in making the fix and adding tests to prevent it from regressing? I'll review any PRs 😄

@07akioni
Copy link
Author

Hmm; this ought to be fixed, it should work as you expect and has some special handling already: https://github.com/andrejewski/himalaya/blob/master/src/tags.js#L5

@07akioni are you interested in making the fix and adding tests to prevent it from regressing? I'll review any PRs 😄

I may have a try later. In this period I am a little busy😂

@Noobiest9
Copy link

Hi,

I'm also seeing template tags getting parsed (although in my case, it's cool).

input:

<select style="width:200px;height:20px;font-size:11px;" v-model="content.dataRef">
       <template v-for="src in dataRefs">
              <option :value="src">{{ src }}</option>
       </template>
 </select>

output:

[
  {
    "type": "element",
    "tagName": "select",
    "attributes": [
      {
        "key": "style",
        "value": "width:200px;height:20px;font-size:11px;"
      },
      {
        "key": "v-model",
        "value": "content.dataRef"
      }
    ],
    "children": [
      {
        "type": "element",
        "tagName": "template",
        "attributes": [
          {
            "key": "v-for",
            "value": "src in dataRefs"
          }
        ],
        "children": [
          {
            "type": "text",
            "content": "<option :value=\"src\">{{ src }}</option>"
          }
        ]
      }
    ]
  }
]

In the 'parser.js' file I didn't really see where the childlessTags get a look, but line 121 might be a fit with another || arrayIncludes(childless...).

If I knew how to use Github I'd test this theory out and do PR, ... but check the name (Noob). Thanks again for this work!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants