Skip to content
This repository has been archived by the owner on Apr 1, 2024. It is now read-only.

Releases: hhvm/xhp-lib

Small improvements

14 Jul 17:59
Compare
Choose a tag to compare
  • Add :picture
  • Allow arbitrary values for :input autocomplete attribute
  • Support num and arraykey attributes
  • Add minimum version of HHVM (3.6.0) to composer.json

2.2.1: small improvements

29 Jun 21:35
Compare
Choose a tag to compare
  • if an attribute is specified as callable, raise an exception that states it's unsupported in XHP-Lib >=2.0 instead of the generic 'unknown attribute type' error
  • Support non-numeric values for :input min/max eg date or time

Nested validation and AsyncXHP bugfix

26 May 20:59
Compare
Choose a tag to compare

This release fixes an issue where ❌composable-element would not fully
process nested structures, except for rendering them. In particular,
while children were always validated for root elements, they would not
always be validated for deeper nested children.

This release may uncover bugs in code that depends on children not being
validated.

This has been fixed by combining the render and validation steps into
one recursive process - this may change the execution order of AsyncXHP
elements, however this is already undefined by HHVM.

Increased usability of XHPHelpers, attribute coercion now throws exceptions

01 May 17:24
Compare
Choose a tag to compare
  • For classes using XHPHelpers, attributes are automatically transferred to the root element; for example, if you call $element->setAttribute('id', 'foo') and that element renders a div, that div will have the id attribute set. The class attribute is appended instead of replacing the existing value
  • In line with the rest of Hack and the increased typechecker strictness in HHVM 3.7, incorrect attribute types now throw an exception instead of logging an E_USER_DEPRECATED
  • This release also contains the change to the 2.0.x branch reducing the boilerplate for XHPAsync - see the v2.0.2 release notes for details

XHPHelpers Example

class :foo extends :x:element {
  use XHPHelpers;

  attribute :xhp:html-element;

  protected function render(): XHPRoot {
    return <div />;
  }
}

// v2.0.x: <div></div>
// v2.1.x: <div id="bar"></div>
var_dump((<foo id="bar" />)->toString());

Attribute Types Example

class :foo extends :x:element {
  attribute int bar @required;
  // ...
}

// Typechecker error in HHVM 3.7+
// E_USER_DEPRECATED in XHP-Lib 2.0.x
// Exception in XHP-Lib 2.1+
$x = <foo bar="123" />; 

// Typechecker error in HHVM 3.7+
// E_USER_DEPRECATED in XHP-Lib 2.0.x
// Exception in XHP-Lib 2.1+
$x = <foo bar={"123"} />;

// Correct
$x = <foo bar={123} />;

You can revert to the previous behavior as follows:

XHPAttributeCoercion::SetMode(XHPAttributeCoercionMode::LOG_DEPRECATION);

This will not remove the typechecker errors, and we expect to remove this option in v3.

Decreased boilerplate for XHPAsync

01 May 16:59
Compare
Choose a tag to compare

Using the XHPAsync now implicitly marks your class as implementing XHPAwaitable.

Before:

class :foo extends :x:element  implements XHPAwaitable {
  use XHPAsync;
}

After:

class :foo extends :x:element {
  use XHPAsync;
}

You can still explicitly mark your classes as implementing XHPAwaitable if you prefer, or for backwards compatibility.

2.0 bugfixes

15 Apr 18:23
Compare
Choose a tag to compare

2.0: Hack

06 Apr 16:55
Compare
Choose a tag to compare
  • Convert to Hack. The 1.x release series is still supported for users of PHP5
  • Added AwaitableXHP; this allows you to build efficient XHP components where data fetching requirements are an implementation detail instead of part of the API they present
  • Attribute coercion is now much stricter, and raises an E_DEPRECATED. In a future release, the Hack typechecker will consider any coercion to be an error, and XHP-Lib will throw an exception.
  • Added XHPUnsafeRenderable and XHPAlwaysValidChild interfaces, making it easier to include markup from other sources in an XHP tree. See MIGRATING.md for more information
  • Split out getID(), addClass(), transferAttributes() and friends from :x:html-element to a new XHPHelpers trait, which implements the new HasXHPHelpers interface
  • Add new XHPRoot interface, implemented by :x:primitive and :x:composable-element. This is the return type of render()
  • Removed Callable attribute type, as this is not supported by Hack
  • Functions that dealt with arrays (eg getAttributes()) now use Vector, Map, or Set
  • Added reflection; ReflectionXHPClass is the main entry point

Composer installable, BSD-licensed, embedding non-XHP markup

02 Mar 20:20
Compare
Choose a tag to compare
  • The PHP5 extension has been split to https://github.com/facebookarchive/xhp-php5-extension
  • As this repository no longer includes a PHP5 extension, the Zend and PHP licenses are not appropriate. Relicensed as BSD
  • You can now add XHP to your composer-based PHP project (facebook/xhp-lib)
  • Other markup can now be embedded in XHP via the XHPUnsafeRenderable and XHPAlwaysValidChild interfaces - see MIGRATING.md for details
  • Provide toString() as well as __toString(). They are identical, however calling toString() will give you much nicer backtraces
  • validation was overly strict. Relaxed.
  • added HTML conditional comments
  • improved support for Hack Vectors, Sets, and Maps
  • support nested array specifications - eg array<array<string, int>>
  • single quotes are now allowed in HTML attributes without being escaped
  • added Contexts (see 1e1825c)

This release supports PHP5 and HHVM.

Branch Changes

The "hack" branch will shortly be merged into master. If you are already using composer to track master, please start tracking the '1.x' branch instead, or change to using ~1.6.

PHP 5.5 Support

16 Sep 21:44
Compare
Choose a tag to compare

Considerable improvements have been made since 1.3.9, namely support for PHP 5.5 as well as upgrades to HTML5 specifications and bug fixes.