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

Renaming var flash to flashData #744

Merged
merged 1 commit into from
May 9, 2019
Merged

Renaming var flash to flashData #744

merged 1 commit into from
May 9, 2019

Conversation

Abdulwahaab710
Copy link
Member

@Abdulwahaab710 Abdulwahaab710 commented May 8, 2019

Previously in this PR #695 I moved the flash message script block to a separate file to make it play well with Content Security Policy. When I moved them to a separate file I had to pass the data for the flash through data attribute.

<% content_for :javascript do %>
<%= content_tag(:div, nil, id: 'shopify-app-flash', data: { flash: { notice: flash[:notice], error: flash[:error] } }) %>
<% end %>

In flash_message.js I fetch the data and store them in a variable called flash

var flash = JSON.parse(document.getElementById('shopify-app-flash').dataset.flash);

The issue is that there is already a function called flash in the same file

document.addEventListener(eventName, function flash() {

So there is a conflict with the names, and that's what I am trying to accomplish in this PR, which is renaming the variable flash to flashData.

@Abdulwahaab710 Abdulwahaab710 requested a review from a team as a code owner May 8, 2019 21:51
@tiffanytse
Copy link
Contributor

Could you provide more context why you think these need to be renamed?

@Abdulwahaab710
Copy link
Member Author

👋 Hey @tiffanytse,
In this PR #695 I moved the flash message script block to a separate file to make it play well with Content Security Policy. When I moved them to a separate file I had to pass the data for the flash through data attribute.

<% content_for :javascript do %>
<%= content_tag(:div, nil, id: 'shopify-app-flash', data: { flash: { notice: flash[:notice], error: flash[:error] } }) %>
<% end %>

In flash_message.js I fetch the data and store them in a variable called flash

var flash = JSON.parse(document.getElementById('shopify-app-flash').dataset.flash);

The issue is that there is already a function called flash in the same file

document.addEventListener(eventName, function flash() {

So there is a conflict with the names, that's why I want to rename the variable flash to flashData.

@tiffanytse tiffanytse requested a review from katiedavis May 9, 2019 19:26
Copy link
Contributor

@katiedavis katiedavis left a comment

Choose a reason for hiding this comment

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

LG2M

@Abdulwahaab710 Abdulwahaab710 changed the title [WIP] Renaming var flash to flashData Renaming var flash to flashData May 9, 2019
Copy link
Contributor

@clayton-shopify clayton-shopify left a comment

Choose a reason for hiding this comment

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

Looks correct. 👍

@Abdulwahaab710 Abdulwahaab710 merged commit 8f2403f into master May 9, 2019
@Abdulwahaab710 Abdulwahaab710 deleted the fixing-flash branch May 9, 2019 21:14
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.

4 participants