summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/tokenizer/interface.rs17
-rw-r--r--src/tokenizer/mod.rs4
2 files changed, 17 insertions, 4 deletions
diff --git a/src/tokenizer/interface.rs b/src/tokenizer/interface.rs
index 35ba9c5..ebb8569 100644
--- a/src/tokenizer/interface.rs
+++ b/src/tokenizer/interface.rs
@@ -7,10 +7,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-use markup5ever::interface::Attribute;
use tendril::StrTendril;
use crate::tokenizer::states;
-use markup5ever::LocalName;
+use markup5ever::{LocalName, QualName};
use std::borrow::Cow;
pub use self::TagKind::{EndTag, StartTag};
@@ -44,6 +43,20 @@ pub enum TagKind {
EndTag,
}
+/// A tag attribute, e.g. `class="test"` in `<div class="test" ...>`.
+///
+/// The namespace on the attribute name is almost always ns!("").
+/// The tokenizer creates all attributes this way, but the tree
+/// builder will adjust certain attribute names inside foreign
+/// content (MathML, SVG).
+#[derive(PartialEq, Eq, PartialOrd, Ord, Clone, Debug)]
+pub struct Attribute {
+ /// The name of the attribute (e.g. the `class` in `<div class="test">`)
+ pub name: QualName,
+ /// The value of the attribute (e.g. the `"test"` in `<div class="test">`)
+ pub value: StrTendril,
+}
+
/// A tag token.
#[derive(PartialEq, Eq, Clone, Debug)]
pub struct Tag {
diff --git a/src/tokenizer/mod.rs b/src/tokenizer/mod.rs
index 6c5823f..c6f7276 100644
--- a/src/tokenizer/mod.rs
+++ b/src/tokenizer/mod.rs
@@ -11,7 +11,7 @@
pub use self::interface::{CharacterTokens, EOFToken, NullCharacterToken, ParseError};
pub use self::interface::{CommentToken, DoctypeToken, TagToken, Token};
-pub use self::interface::{Doctype, EndTag, StartTag, Tag, TagKind};
+pub use self::interface::{Doctype, EndTag, StartTag, Tag, TagKind, Attribute};
pub use self::interface::{TokenSink, TokenSinkResult};
use self::states::{DoctypeIdKind, Public, System};
@@ -33,7 +33,7 @@ use std::mem::replace;
pub use crate::util::buffer_queue::{BufferQueue, FromSet, NotFromSet, SetResult};
use tendril::StrTendril;
-use markup5ever::{Attribute, LocalName, QualName};
+use markup5ever::{LocalName, QualName};
mod char_ref;
mod interface;