Skip to content

Commit

Permalink
Add a dummy implementation of contentEditable
Browse files Browse the repository at this point in the history
  • Loading branch information
Alan Jeffrey committed Apr 22, 2020
1 parent b60c70b commit c00eb62
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 15 deletions.
21 changes: 21 additions & 0 deletions components/script/dom/htmlelement.rs
Expand Up @@ -568,6 +568,27 @@ impl HTMLElementMethods for HTMLElement {
},
);
}

// https://html.spec.whatwg.org/multipage/#dom-contenteditable
fn ContentEditable(&self) -> DOMString {
// TODO: https://github.com/servo/servo/issues/12776
self.upcast::<Element>()
.get_attribute(&ns!(), &local_name!("contenteditable"))
.map(|attr| DOMString::from(&**attr.value()))
.unwrap_or_else(|| DOMString::from("inherit"))
}

// https://html.spec.whatwg.org/multipage/#dom-contenteditable
fn SetContentEditable(&self, _: DOMString) {
// TODO: https://github.com/servo/servo/issues/12776
warn!("The contentEditable attribute is not implemented yet");
}

// https://html.spec.whatwg.org/multipage/#dom-contenteditable
fn IsContentEditable(&self) -> bool {
// TODO: https://github.com/servo/servo/issues/12776
false
}
}

fn append_text_node_to_fragment(document: &Document, fragment: &DocumentFragment, text: String) {
Expand Down
6 changes: 3 additions & 3 deletions components/script/dom/webidls/ElementContentEditable.webidl
Expand Up @@ -5,7 +5,7 @@
// https://html.spec.whatwg.org/multipage/#elementcontenteditable
[Exposed=Window]
interface mixin ElementContentEditable {
// [CEReactions]
// attribute DOMString contentEditable;
// readonly attribute boolean isContentEditable;
[CEReactions]
attribute DOMString contentEditable;
readonly attribute boolean isContentEditable;
};
12 changes: 0 additions & 12 deletions tests/wpt/metadata/html/dom/idlharness.https.html.ini
Expand Up @@ -2403,9 +2403,6 @@
[HTMLMeterElement interface: document.createElement("meter") must inherit property "value" with the proper type]
expected: FAIL

[HTMLElement interface: attribute isContentEditable]
expected: FAIL

[HTMLEmbedElement interface: attribute align]
expected: FAIL

Expand Down Expand Up @@ -2616,9 +2613,6 @@
[HTMLInputElement interface: document.createElement("input") must inherit property "useMap" with the proper type]
expected: FAIL
[HTMLElement interface: document.createElement("noscript") must inherit property "isContentEditable" with the proper type]
expected: FAIL
[HTMLAreaElement interface: attribute ping]
expected: FAIL
Expand Down Expand Up @@ -3234,9 +3228,6 @@
[HTMLMarqueeElement interface: document.createElement("marquee") must inherit property "trueSpeed" with the proper type]
expected: FAIL
[HTMLElement interface: attribute contentEditable]
expected: FAIL
[HTMLInputElement interface: createInput("file") must inherit property "align" with the proper type]
expected: FAIL
Expand Down Expand Up @@ -3579,9 +3570,6 @@
[HTMLTableCellElement interface: document.createElement("th") must inherit property "ch" with the proper type]
expected: FAIL

[HTMLElement interface: document.createElement("noscript") must inherit property "contentEditable" with the proper type]
expected: FAIL

[HTMLTextAreaElement interface: document.createElement("textarea") must inherit property "autocomplete" with the proper type]
expected: FAIL

Expand Down

0 comments on commit c00eb62

Please sign in to comment.