-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rewrite attribute transfer section to use ...splat
- Loading branch information
Showing
4 changed files
with
46 additions
and
33 deletions.
There are no files selected for viewing
7 changes: 3 additions & 4 deletions
7
guides/hack/21-XHP/16-extending-examples/attribute-transfer.inc.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,14 @@ | ||
<?hh // partial | ||
<?hh | ||
|
||
use namespace Facebook\XHP\Core as x; | ||
use type Facebook\XHP\HTML\{div, XHPAttributeClobbering_DEPRECATED}; | ||
|
||
final xhp class ui_my_good_box extends x\element { | ||
attribute :Facebook:XHP:HTML:div; // inherit attributes from <div> | ||
// Make sure that attributes are transferred automatically when rendering. | ||
use XHPAttributeClobbering_DEPRECATED; | ||
attribute int extra_attr; | ||
|
||
protected async function renderAsync(): Awaitable<x\node> { | ||
// returning this will transfer any attribute set on this custom object | ||
return <div class="my-good-box">{$this->getChildren()}</div>; | ||
return <div id="id1" {...$this} class="class1">{$this->getChildren()}</div>; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
guides/hack/21-XHP/16-extending-examples/attribute-transfer.php.hhvm.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
<div class="my-good-box" title="My Good box"></div> | ||
<div id="id2" class="class1"></div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters