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

strict and loose mode #59

Open
3 of 9 tasks
DrSensor opened this issue Jan 31, 2023 · 0 comments
Open
3 of 9 tasks

strict and loose mode #59

DrSensor opened this issue Jan 31, 2023 · 0 comments
Labels
enhancement New feature or request optimization Because speed, memory consumption, and bundle size are important priority: medium Something that should be tackled

Comments

@DrSensor
Copy link
Owner

DrSensor commented Jan 31, 2023

By default this framework operate on loose mode where __MODE__ === "loose". All scripts that only have strict mode have smaller bundle size and it's organized on strict/ folder. For example,

<script async src="https://esm.run/nusa/strict/render-scope"></script>

will define <render-scope> that only operate on strict mode.

strict mode

  • Require @bind decorator (unlike controlled loose mode, binding work on class parent and ancestors too without traversing)
  • Can be enforced via strict attribute when using default (loose) scripts
  • <render-scope> doesn't handle inline <script> and <style> module (where it has attribute type=module/*)

loose mode

  • Bind class accessor
  • Bind class getter/setter
  • Bind class field
  • Bind class method()
  • By default, all binding apply to all class parent and ancestors (Traverse Binding #57)
  • Traverse Binding #57 can be controlled via traverse-depth=<uint> attribute or class extends traverse(...Classes).extends(Class) helper

💡 Hint: traverse binding and binding class field can be implemented at the same time

if (name in instance) {
  desc[name].set = function(value) {
    super[name] = databank[index] = value
  }
}
Object.defineProperties(instance, desc)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request optimization Because speed, memory consumption, and bundle size are important priority: medium Something that should be tackled
Development

No branches or pull requests

1 participant