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

Treat boolean attributes as HTML properties #188

Merged
merged 2 commits into from
Dec 13, 2016
Merged

Treat boolean attributes as HTML properties #188

merged 2 commits into from
Dec 13, 2016

Conversation

skyrpex
Copy link
Contributor

@skyrpex skyrpex commented Apr 28, 2016

HTML properties shouldn't have value. Attributes with boolean values will now be represented as HTML properties.

Given this Blade snippet:

{!! Form::text('timezone', null, ['class' => 'form-control', 'placeholder' => 'Timezone', 'my-property' => true]); !!}

It will compile to:

<input class="form-control" placeholder="Timezone" my-property name="timezone" type="text" id="timezone">

@mlantz
Copy link
Member

mlantz commented Jun 10, 2016

Unit test please :)

@decadence
Copy link

@skyrpex why did you stop? Make unit tests please. I think your changes are useful for readonly or disabled attributes. I hope false value does not output attribute.

@decadence
Copy link

#208

@skyrpex
Copy link
Contributor Author

skyrpex commented Aug 16, 2016

This should do it.

@decadence
Copy link

decadence commented Aug 16, 2016

Guys sorry about not relative question, but who is able to review PRs on this repo?
I don't see much activity here about it and I see some PRs without attention.
I would like anyone to consider my suggestion here: #217

@skyrpex
Copy link
Contributor Author

skyrpex commented Sep 20, 2016

Sigh...

@andrzejkupczyk
Copy link

This is good for custom attributes. If you care about W3C standards, check this PR instead.

@EspadaV8
Copy link
Contributor

Copy/pasting from my comment in #252

@andrzejkupczyk When it mentions 'the empty string' that also allows it to be omitted. You can see examples of boolean attributes here W3C Boolean Attributes

Here is an example of a checkbox that is checked and disabled. The checked and disabled attributes are the boolean attributes.

<label><input type=checkbox checked name=cheese disabled> Cheese</label>

This could be equivalently written as this:

<label><input type=checkbox checked=checked name=cheese disabled=disabled> Cheese</label>

You can also mix styles; the following is still equivalent:

<label><input type='checkbox' checked name=cheese disabled=""> Cheese</label>

The information about omitting empty string values is mentioned in the secion A Quick Introduction to HTML about 4 paragraphs in (emphasis mine)

Attributes are placed inside the start tag, and consist of a name and a value, separated by an "=" character. The attribute value can remain unquoted if it doesn't contain space characters or any of " ' ` = < or >. Otherwise, it has to be quoted using either single or double quotes. The value, along with the "=" character, can be omitted altogether if the value is the empty string.

@skyrpex
Copy link
Contributor Author

skyrpex commented Oct 25, 2016

👍

On Tue, Oct 25, 2016, 12:07 AM Andrew Smith notifications@github.com
wrote:

Copy/pasting from my comment in #252
#252

@andrzejkupczyk https://github.com/andrzejkupczyk When it mentions 'the
empty string' that also allows it to be omitted. You can see examples of
boolean attributes here W3C Boolean Attributes
https://www.w3.org/TR/html5/single-page.html#boolean-attributes

Here is an example of a checkbox that is checked and disabled. The checked
and disabled attributes are the boolean attributes.

Cheese

This could be equivalently written as this:


Cheese

You can also mix styles; the following is still equivalent:


Cheese

The information about omitting empty string values is mentioned in the
secion A Quick Introduction to HTML
https://www.w3.org/TR/html5/single-page.html#intro-early-example about
4 paragraphs in (emphasis mine)

Attributes are placed inside the start tag, and consist of a name and a
value, separated by an "=" character. The attribute value can remain
unquoted if it doesn't contain space characters or any of " ' ` = < or >.
Otherwise, it has to be quoted using either single or double quotes. The
value, along with the "=" character, can be omitted altogether if the value
is the empty string.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#188 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABBxEPN2sNl-BKGjMHp2dE3_GPgeVS7Fks5q3SwXgaJpZM4IR2tM
.

@mlantz mlantz merged commit 8956f00 into LaravelCollective:5.2 Dec 13, 2016
@skyrpex skyrpex deleted the patch-1 branch December 13, 2016 15:09
@alexmglover
Copy link

alexmglover commented Mar 8, 2017

It looks like this change is not available on 5.3. Is this intentional?

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

7 participants