-
-
Notifications
You must be signed in to change notification settings - Fork 46
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
Omitting Script attribute if none or default #53
Omitting Script attribute if none or default #53
Conversation
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 is great - I just have a couple nit-picks for you to address, and then I can merge.
Thanks!
@weierophinney The CI failed because of the required PHP Version (private const needs PHP 7.1). If we change this, we cannot require PHP 5.6 anymore. Wouldn't this be a BC Break? |
@DennisDobslaf we can bump PHP version to 7.2 for the next minor, please see our policy here: We are not considering bumping PHP version in minor update as a BC break. |
Well, but this is not a minor update but a fix, isn't it? So, should it be minor update with private const plus PHP 7.2 requirement Should this be a discussion in the slack channel? |
php 5.6, 7, and 7.1 can be removed from |
Any work to do for me now? |
I think there are some misunderstandings. This is a bug fix and the fix should be released with a mini release. This allows us to make a release now and not to wait for the next minor version. Which means for this pull request:
|
I'll do |
@DennisDobslaf |
7920288
to
8825d24
Compare
@froschdesign I'm fine with your notes. |
@@ -33,6 +33,7 @@ class HeadScript extends Placeholder\Container\AbstractStandalone | |||
*/ | |||
const FILE = 'FILE'; | |||
const SCRIPT = 'SCRIPT'; | |||
const DEFAULT_SCRIPT_TYPE = 'text/javascript'; |
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 constant should also be used in Laminas\View\Helper\InlineScript
:
laminas-view/src/Helper/InlineScript.php
Lines 30 to 36 in 9512a19
public function __invoke( | |
$mode = self::FILE, | |
$spec = null, | |
$placement = 'APPEND', | |
array $attrs = [], | |
$type = 'text/javascript' | |
) { |
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.
Like $type = HeadScript::DEFAULT_SCRIPT_TYPE
or by making a separated "Enum" Class?
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.
The InlineScript
helper is an extension of the HeadScript
helper:
laminas-view/src/Helper/InlineScript.php
Line 15 in 9512a19
class InlineScript extends HeadScript |
Therefore: $type = self::DEFAULT_SCRIPT_TYPE
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.
Oh, I've overlooked this fact.
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.
Probably, as we cannot add visibility on the constant, we should add php annotation @internal
for now. Then in next minor, when we bump php version we can use private/protected visibility.
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.
added your suggestion @michalbundyra
a1809e7
to
cbef6ab
Compare
Seems very legit. I will change it and expand the unit test.
Michał Bundyra <[email protected]> schrieb am Di., 18. Aug. 2020,
15:32:
… ***@***.**** commented on this pull request.
------------------------------
In src/Helper/HeadScript.php
<#53 (comment)>:
> @@ -401,7 +406,10 @@ public function itemToString($item, $indent, $escapeStart, $escapeEnd)
$addScriptEscape = ! (isset($item->attributes['noescape'])
&& filter_var($item->attributes['noescape'], FILTER_VALIDATE_BOOLEAN));
- if (empty($item->type) && $this->view && $this->view->plugin('doctype')->isHtml5()) {
+ if ((empty($item->type) || $item->type === self::DEFAULT_SCRIPT_TYPE)
I think check should be case insensitive, so we should use
strtolower($item->type) instead. What do you think?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#53 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAVYJJ777YATENRXB3S765LSBJ7HDANCNFSM4P242EDA>
.
|
cbef6ab
to
b0daf88
Compare
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.
One final change, and I think this is ready!
Ommiting the script attribute if its either empty or default (text/javascript) and the doctype is set to HTML5. Referring to: https://html.spec.whatwg.org/multipage/scripting.html#the-script-element Signed-off-by: Dennis Dobslaf <[email protected]>
b0daf88
to
5d6ebb0
Compare
@weierophinney I think it is ready now |
Any news on this one? Do I have to do some work? |
ping @weierophinney |
@samsonasik |
Merged 🎉 @DennisDobslaf thank you for the PR ;) |
Ommiting the script attribute if its either empty or default (text/javascript) and the doctype is set to HTML5.
Referring to: https://html.spec.whatwg.org/multipage/scripting.html#the-script-element
Signed-off-by: Dennis Dobslaf [email protected]
Description