Skip to content

Commit

Permalink
Merge branch '8.x' into bug/blade-component-falsy-slots
Browse files Browse the repository at this point in the history
  • Loading branch information
danharrin committed Aug 25, 2021
2 parents 19d3158 + b830dcb commit 716835e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 23 deletions.
35 changes: 17 additions & 18 deletions src/Illuminate/View/ComponentSlot.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,11 @@ class ComponentSlot implements Htmlable
public function __construct($contents = '', $attributes = [])
{
$this->contents = $contents;

$this->withAttributes($attributes);
}

/**
* Set the extra attributes that the slot should make available.
*
* @param array $attributes
* @return $this
*/
public function withAttributes(array $attributes)
{
$this->attributes = new ComponentAttributeBag($attributes);

return $this;
}

/**
* Get the slot's HTML string.
* Get the HTML string.
*
* @return string
*/
Expand All @@ -58,7 +44,7 @@ public function toHtml()
}

/**
* Determine if the slot is empty.
* Determine if the given slot is empty.
*
* @return bool
*/
Expand All @@ -68,7 +54,7 @@ public function isEmpty()
}

/**
* Determine if the slot is not empty.
* Determine if the given slot is not empty.
*
* @return bool
*/
Expand All @@ -78,7 +64,20 @@ public function isNotEmpty()
}

/**
* Get the slot's HTML string.
* Set the extra attributes that the slot should make available.
*
* @param array $attributes
* @return $this
*/
public function withAttributes(array $attributes)
{
$this->attributes = new ComponentAttributeBag($attributes);

return $this;
}

/**
* Get the HTML string.
*
* @return string
*/
Expand Down
8 changes: 3 additions & 5 deletions src/Illuminate/View/Concerns/ManagesComponents.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ protected function componentData()
* Start the slot rendering process.
*
* @param string $name
* @param string|null $content
* @param array $attributes
* @param string|null $content
* @return void
*/
public function slot($name, $content = null, $attributes = [])
Expand All @@ -147,11 +147,9 @@ public function endSlot()
$this->slotStack[$this->currentComponent()]
);

[$currentName, $currentAttributes] = $currentSlot;
[$currentSlotName, $currentSlotAttributes] = $currentSlot;

$this->slots[$this->currentComponent()][$currentName] = new ComponentSlot(
trim(ob_get_clean()), $currentAttributes
);
$this->slots[$this->currentComponent()][$currentSlotName] = new ComponentSlot(trim(ob_get_clean()), $currentSlotAttributes);
}

/**
Expand Down

0 comments on commit 716835e

Please sign in to comment.