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

Expose Compiler to extend features #18

Closed
terinjokes opened this issue Nov 4, 2014 · 6 comments
Closed

Expose Compiler to extend features #18

terinjokes opened this issue Nov 4, 2014 · 6 comments

Comments

@terinjokes
Copy link

No description provided.

@lazd
Copy link
Owner

lazd commented Nov 4, 2014

@terinjokes, it's easy to expose the Compiler constructor, but there are a number of utility methods that aren't on Compiler's prototype:

  • usesVariables(string)
  • safe(string)
  • isBlank(string)
  • isInline(node)
  • isFragCandidate(node)
  • hasSubstitutions(node)
  • hasConditionAttributesOrHandles(node)
  • isRealElement(node)

I'll move those to the prototype, then export Compiler so it's available. Would that give you what you need?

@terinjokes
Copy link
Author

@lazd I honestly just needed to override setTextContent to use a utility library, since el.textContent isn't cross-browser enough for my needs.

(That said, all the usages of setTextContent went away when I fixed the stripWhitespace bug I'm clean up to PR to you…)

@lazd lazd closed this as completed in 5fc3a7b Nov 4, 2014
@lazd
Copy link
Owner

lazd commented Nov 4, 2014

@terinjokes, I went ahead and simply exposed the Compiler constructor in the exported module. You can now extend it and override setTextContent or simply monkey-patch the prototype.

That should handle your use case. If the other functions I mentioned become required, we can just throw them on Compiler's prototype.

This issue opened my eyes to the fact that people are definitely going to want to change DOMly's output in various ways, so the compiler should facilitate that. I'll be thinking about that in general, let me know if you have thoughts on how to expose that kind of flexibility in a simpler way.

@terinjokes
Copy link
Author

@lazd how often do you do releases?

@lazd
Copy link
Owner

lazd commented Nov 6, 2014

I haven't released yet as I was trying to get a solid test on another issue I closed with @cif. I'll release tomorrow.

@lazd
Copy link
Owner

lazd commented Nov 17, 2014

@terinjokes, a bit late, but I've released DOMly@0.0.7 that includes the fix for this issue.

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