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

Consider exporting InsertionMode enum #531

Open
ICodeMyOwnLife opened this issue May 6, 2022 · 4 comments
Open

Consider exporting InsertionMode enum #531

ICodeMyOwnLife opened this issue May 6, 2022 · 4 comments

Comments

@ICodeMyOwnLife
Copy link

When creating a custom parser we need to check the insertionMode field against a value. Without the InsertionMode enum exported we have to use a magic number or redefine another enum within our codebase.

Screen Shot 2022-05-06 at 11 06 13 AM

Is there any reason preventing us from exporting the enum?

@fb55
Copy link
Collaborator

fb55 commented May 6, 2022

InsertionMode is actually exported: https://github.com/inikulin/parse5/blob/master/packages/parse5/lib/index.ts

We mark it as internal, to avoid clutter in the documentation. But there is nothing stopping you from importing it.

@fb55 fb55 closed this as completed May 6, 2022
@ICodeMyOwnLife
Copy link
Author

Hey @fb55 I could miss something but InsertionMode was not exported inside parser/index.ts and I couldn't find anywhere that indirectly exports the enum.

@fb55 fb55 reopened this May 9, 2022
@fb55
Copy link
Collaborator

fb55 commented May 9, 2022

I was thinking of tokenizer modes – sorry about the confusion. I'm not sure how useful exporting insertion modes would be, as the parser is pretty hard to extend in the current form (_processToken is only called when re-processing tokens).

@ICodeMyOwnLife
Copy link
Author

The authors of single-spa-layout extended Parser in their project https://github.com/single-spa/single-spa-layout/blob/main/src/server/CustomParser.js.
I'm rewriting that piece of code into TypeScript (after upgrading the parse5 dependency to v7) for a project in my company and that's when I encountered InsertionMode enum.
I think we could export the enum inside its file but not in the package index. The enum itself was marked as internal so that people use it at their own risk.

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

2 participants