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

Add addText method to TwiML classes #355

Merged
merged 3 commits into from
Jun 14, 2018
Merged

Add addText method to TwiML classes #355

merged 3 commits into from
Jun 14, 2018

Conversation

ekarson
Copy link
Contributor

@ekarson ekarson commented Jun 13, 2018

Allow adding arbitrary text under TwiML nodes via the new method addText

@ekarson ekarson requested a review from cjcodes June 13, 2018 23:52
*/
/* jshint ignore:end */
MessagingResponse.prototype.redirect = function redirect(attributes, url) {
this.response.ele('Redirect', attributes, url);
return new Redirect(this.response.ele('Redirect', attributes, url));
Copy link
Member

Choose a reason for hiding this comment

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

Can you explain what the change from response.ele -> new Element does here? Was response.ele just the object before?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

response.ele means "add a new element with the name 'Redirect'" -- it mutated the response without returning anything.

The new code still does the mutation, but then it returns the newly-created element node (wrapped in a class named after the element).

@ekarson ekarson merged commit c34ebf0 into master Jun 14, 2018
@ekarson ekarson deleted the DX-307_node branch June 14, 2018 21:03
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.

2 participants