Releases: hhvm/xhp-lib
Support HHVM 3.28
This release:
- supports HHVM 3.28
- adds <script integrity> attribute to support the Subresource Integrity spec
- adds support for XHPUnsafeRenderable in HTML attributes
Relicense to MIT, support the attribute spread operator
This release:
- is available under the MIT license
- adds support for the XHP spread operator (available in HHVM 3.24+)
The XHP Spread Operator
This is intended to be a safer replacement for the implicit attribute copying available via XHPHelpers
; we expect to remove XHPHelpers
from XHP 3.0.
class :inner extends :x:element {
attribute string color, int age;
}
class :outer-old extends :x:element {
use XHPHelpers;
attribute string color, int age;
public function render(): :xhp {
// `age` attribute is implicitly copied
return <inner color="red" />;
}
}
class :outer-new extends :x:element {
attribute string color, int age;
public function render(): :xhp {
// Explicitly copy all attributes from `$this` - however, the override of color takes precedence
return <inner {...$this} color="red" />;
}
}
The typechecker is able to validate types - for example:
class :outer-invalid extends :x:element {
attribute string color, float age;
public function render(): :xhp {
// Type error:
// Invalid xhp value for attribute :age in :inner
// This is an int
// It is incompatible with a float
return <inner {...$this} />;
}
}
Support additional typechecker restrictions
This release supports:
safe_array=true
andsafe_vector_array=true
enable_experimental_tc_features=no_fallback_in_namespaces
(nightlies, expected in 3.25)
Support HHVM 3.24, require HHVM 3.23+
v2.5.0 Add string cast for 3.24 in tests
Support for TypeAssert v3, disable attribute validation by default
- this release uses TypeAssert v3 instead of v2, allowing it to be used in new projects
- this release splits the API for enabling/disabling validation into separate options for child validation and attribute validation.
:xhp::$ENABLE_VALIDATION
no longer exists. - attribute validation is off by default; we aim to remove it completely from a future release
Validation changes
Enabling attribute validation
:xhp::enableAttributeValidation();
Disabling child validation
:xhp::disableChildValidation();
Motivation
- This will allow removing the dependency on
TypeAssert
in the future - The runtime validation isn't as useful now given that the typechecker validates attributes specified when instantiating XHP objects
- The runtime validation is bad for performance
- Keeping the runtime validation in sync with the typechecker has been a frequent source of issues
Caveat
As setAttribute()
is not special-cased in the typechecker, so is now completely unchecked unless validation is enabled.
Support using stable release of fredemmott/type-assert
This library is used to implement support for shapes, and has just released v1.0 - support either v0.2 or v1.x
Support for Shapes, JsonSerializable, Nightlies, E_STRICT
Thanks to @simonwelsh for JsonSerializable.
BC break: contenteditable and draggable attribute types
These are now enum { 'true', 'false' }
attributes instead of bool
, to match the HTML specification. attr=false
is not valid for boolean attributes (either in XHP or the specification), but is valid for these.
Support for HHVM 3.12
Removed a bogus assert - 3.12 makes asserts enabled by default.