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

Fixed bound attributes not rendering for non-data attributes #50479

Closed
wants to merge 6 commits into from

Conversation

dash8x
Copy link

@dash8x dash8x commented Mar 12, 2024

- Fixed bound attributes not rendering for non-data attributes, see pull request laravel#50403
@danharrin
Copy link
Contributor

I think you may need a PR to target 10.x too

@danharrin
Copy link
Contributor

Snapshot tests will need updating with the new compiled syntax

@inxilpro
Copy link
Contributor

I just bumped into this bug as well. This test in the Aire test suite started failing at 10.48. The blade attribute :x-on:keyup="$keyup" no longer ends up in the rendered HTML. I just grabbed @dash8x's fix and it seems to resolve it.

@devajmeireles
Copy link
Contributor

I was able to confirm that the code of this PR also fixes my issues too. Thanks, guys! Now we need to wait for @taylorotwell .

@danharrin
Copy link
Contributor

@inxilpro @devajmeireles depending on the amount of free time you have, it might be worth opening a separate PR to add tests for Blade component usage. Currently, only compilation is tested, so its difficult to find edge cases like this, and if your packages depend on this functionality then it might be worthwhile in the long run :)

@@ -478,7 +478,7 @@ public function testClasslessComponents()
<?php if (isset(\$attributes) && \$attributes instanceof Illuminate\View\ComponentAttributeBag && \$constructor = (new ReflectionClass(Illuminate\View\AnonymousComponent::class))->getConstructor()): ?>
<?php \$attributes = \$attributes->except(collect(\$constructor->getParameters())->map->getName()->all()); ?>
<?php endif; ?>
<?php \$component->withAttributes(['name' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute(\$componentData['data']['name'] ?? null),'age' => 31,'wire:model' => 'foo']); ?>\n".
<?php \$component->withAttributes(['name' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute(array_key_exists('src', $componentData['data'] ?? []) ? (\$componentData['data']['src'] ?? null) : 'Taylor'),'age' => 31,'wire:model' => 'foo']); ?>\n".
Copy link
Contributor

Choose a reason for hiding this comment

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

Aren't these src references supposed to be name?

Copy link
Contributor

Choose a reason for hiding this comment

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

There are a few tests containing this

Copy link
Author

Choose a reason for hiding this comment

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

Sorry, my bad. Fixed those now

@driesvints
Copy link
Member

Thanks. We're reverting the original PR instead: #50482

@driesvints driesvints closed this Mar 12, 2024
@danharrin
Copy link
Contributor

@driesvints that's a shame, can it be tried again in 11.x with these proposed changes, considering it is a major version?

@driesvints
Copy link
Member

@danharrin I don't know. You can try a new PR with new tests that prove the breaking changes don't re-occur. Then maybe Taylor can reconsider it. Given this is all very brittle I wouldn't mess with it myself.

@binaryfire
Copy link

I also hope this can be revisited with the proposed fixes. It’s a nice performance improvement.

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.

6 participants