-
Notifications
You must be signed in to change notification settings - Fork 36
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
[STRF-10120] paper-handlebars - resource hints should include the proper values for PreloadResourceType #212
Conversation
@@ -48,11 +48,11 @@ function addResourceHint(globals, path, rel, type, cors) { | |||
|
|||
let index = globals.resourceHints.findIndex(({src}) => path === src); | |||
if (index >= 0) { | |||
return; | |||
return path; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There may be scenarios where nested templates include helpers that produce preload hints for the same resource where only the 1st usage of the helper will have the correct effect and the rest, will have unexpected results.
As an example let's take stylesheet
, also, think that there is 1 common-resources
(nested) template that is included in a base
template. The nested template includes the {{{ stylesheet '/asset/css/theme.css' }}}
helper which base
template also includes but, in a linear order, the nested template is rendered before the occurrence of the stylesheet
helper in the base template. For the nested template, the produced link
tag will be correct, it will include a valid href
attribute. The stylesheet
in the base
template:
- (with
return;
) will produce ahref="undefined"
- (with the proposed change) will produce a valid
href
attribute, with the correct URL.
@@ -37,6 +37,35 @@ describe('stylesheet helper', () => { | |||
}); | |||
}); | |||
|
|||
it('should render both link tags correclty but produce only one resource hint', done => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test exemplifies what's described in this comment https://github.com/bigcommerce/paper-handlebars/pull/212/files#r998713714
…per values for PreloadResourceType - fixes issues of duplicated hint returning undefined.
…per values for PreloadResourceType - pr fixes
bbe6f23
to
0f400de
Compare
What? Why?
How was it tested?
cc @bigcommerce/storefront-team