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

[discussion] Access the Context's index and length #654

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sethkinast
Copy link
Contributor

( instead of pushing our own copies onto the stack )

I think anything that manually manipulates the stack directly is a smell. We already have these properties available as context.stack.index and context.stack.of. It doesn't seem to make sense to directly reach into the stack's head and manually set them there.

Instead, we can short-circuit get in these cases.

This also has the side effect of not polluting someone's context.current() with something they didn't expect to be there.

I would just like to get some discussion on this one, I'm not convinced it's correct yet.

@sethkinast
Copy link
Contributor Author

Manually setting $idx and $len to undefined after is especially distasteful to me.

this.of = len;

if(idx === undefined && len === undefined) {
idx = this.tail && this.tail.index;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's this for?

@sethkinast
Copy link
Contributor Author

I would like to get something like this in for Dust@3 in which I don't plan on supporting IE8. Shall we make this a getter?

Copy link

@shivaylamba shivaylamba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm

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

Successfully merging this pull request may close these issues.

None yet

3 participants