use std::ops::Deref;
use std::sync::{Arc, RwLock};
use crate::element::ElementProcessorSet;
use super::{
AttributeDefinition, AttributeDefinitionError, AttributeDefinitionKind, AttributeNameValue,
HTMLAttributeName,
};
pub struct HTMLAttributeDefinition {
attribute_definition: AttributeDefinition,
boolean_attribute: bool,
}
impl HTMLAttributeDefinition {
pub(crate) fn new(
name: Arc<HTMLAttributeName>,
boolean_attribute: bool,
associated_processors: Arc<RwLock<ElementProcessorSet>>,
) -> Result<Self, AttributeDefinitionError> {
Ok(Self {
attribute_definition: AttributeDefinition::new(
AttributeDefinitionKind::Html,
Some(AttributeNameValue::Html(name)),
Some(associated_processors),
)?,
boolean_attribute,
})
}
#[must_use]
pub const fn is_boolean_attribute(&self) -> bool {
self.boolean_attribute
}
#[must_use]
pub const fn as_attribute_definition(&self) -> &AttributeDefinition {
&self.attribute_definition
}
}
impl Deref for HTMLAttributeDefinition {
type Target = AttributeDefinition;
fn deref(&self) -> &Self::Target {
&self.attribute_definition
}
}