WP_HTML_Stack_Event
云策文档标注
概述
WP_HTML_Stack_Event 是 WP_HTML_Processor 内部使用的核心类,用于记录 HTML 处理过程中的栈操作事件。它定义了栈操作的类型和关联数据。
关键要点
- 该类为 WP_HTML_Processor 的内部类,开发者通常不直接使用。
- 定义了栈操作常量:POP(弹出元素)和 PUSH(压入元素)。
- 包含公共属性:token(关联的 WP_HTML_Token)、operation(操作类型)和 provenance(节点类型)。
- 提供构造函数来初始化这些属性。
代码示例
class WP_HTML_Stack_Event {
const POP = 'pop';
const PUSH = 'push';
public $token;
public $operation;
public $provenance;
public function __construct( WP_HTML_Token $token, string $operation, string $provenance ) {
$this->token = $token;
$this->operation = $operation;
$this->provenance = $provenance;
}
}
原文内容
Core class used by the HTML Processor as a record for stack operations.
Description
This class is for internal usage of the WP_HTML_Processor class.
See also
Methods
| Name | Description |
|---|---|
| WP_HTML_Stack_Event::__construct | Constructor function. |
Source
class WP_HTML_Stack_Event {
/**
* Refers to popping an element off of the stack of open elements.
*
* @since 6.6.0
*/
const POP = 'pop';
/**
* Refers to pushing an element onto the stack of open elements.
*
* @since 6.6.0
*/
const PUSH = 'push';
/**
* References the token associated with the stack push event,
* even if this is a pop event for that element.
*
* @since 6.6.0
*
* @var WP_HTML_Token
*/
public $token;
/**
* Indicates which kind of stack operation this event represents.
*
* May be one of the class constants.
*
* @since 6.6.0
*
* @see self::POP
* @see self::PUSH
*
* @var string
*/
public $operation;
/**
* Indicates if the stack element is a real or virtual node.
*
* @since 6.6.0
*
* @var string
*/
public $provenance;
/**
* Constructor function.
*
* @since 6.6.0
*
* @param WP_HTML_Token $token Token associated with stack event, always an opening token.
* @param string $operation One of self::PUSH or self::POP.
* @param string $provenance "virtual" or "real".
*/
public function __construct( WP_HTML_Token $token, string $operation, string $provenance ) {
$this->token = $token;
$this->operation = $operation;
$this->provenance = $provenance;
}
}
Changelog
| Version | Description |
|---|---|
| 6.6.0 | Introduced. |