mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-01-25 02:30:04 +08:00
47 lines
1.0 KiB
Plaintext
Vendored
47 lines
1.0 KiB
Plaintext
Vendored
// From https://docs.hhvm.com/hack/XHP/introduction (MIT licensed)
|
|
|
|
use namespace Facebook\XHP\Core as x;
|
|
use type Facebook\XHP\HTML\{XHPHTMLHelpers, a, form};
|
|
|
|
|
|
final xhp class a_post extends x\element {
|
|
// ^ keyword
|
|
// ^ keyword
|
|
// ^ keyword
|
|
use XHPHTMLHelpers;
|
|
|
|
attribute string href @required;
|
|
// ^ attribute
|
|
attribute string target;
|
|
// ^ keyword
|
|
|
|
<<__Override>>
|
|
protected async function renderAsync(): Awaitable<x\node> {
|
|
$id = $this->getID();
|
|
|
|
$anchor = <a>{$this->getChildren()}</a>;
|
|
// ^ tag.delimiter
|
|
// ^ tag
|
|
$form = (
|
|
<form
|
|
id={$id}
|
|
method="post"
|
|
action={$this->:href}
|
|
target={$this->:target}
|
|
class="postLink">
|
|
{$anchor}
|
|
</form>
|
|
);
|
|
|
|
$anchor->setAttribute(
|
|
'onclick',
|
|
'document.getElementById("'.$id.'").submit(); return false;',
|
|
);
|
|
$anchor->setAttribute('href', '#');
|
|
// ^ method
|
|
|
|
return $form;
|
|
}
|
|
}
|
|
|