Closed Bug 869006 Opened 11 years ago Closed 11 years ago

Comment should be constructable

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla24

People

(Reporter: erik, Assigned: baku)

Details

(Keywords: dev-doc-complete)

Attachments

(1 file, 2 obsolete files)

http://dom.spec.whatwg.org/#comment

Make Comment constructable so that one can do "new Comment('abc')" instead of "document.createComment('abc')"
Assignee: nobody → amarchesini
Attached patch patch (obsolete) — Splinter Review
Attachment #747919 - Flags: review?(Ms2ger)
Comment on attachment 747919 [details] [diff] [review]
patch

Review of attachment 747919 [details] [diff] [review]:
-----------------------------------------------------------------

::: content/base/src/Comment.cpp
@@ +64,5 @@
> +Comment::Constructor(const GlobalObject& aGlobal, const nsAString& aData,
> +                     ErrorResult& aRv)
> +{
> +  nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.Get());
> +  nsRefPtr<Comment> comment = new Comment(window->GetDoc()->NodeInfoManager());

Null-check window and window->GetDoc()

::: content/base/test/test_bug869006.html
@@ +20,5 @@
> +
> +/** Test for Bug 869006 **/
> +
> +var c = new Comment();
> +ok(c, "Comment has been created without content");

Test c.data.

@@ +23,5 @@
> +var c = new Comment();
> +ok(c, "Comment has been created without content");
> +
> +c = new Comment('foo');
> +ok(c, "Comment has been created");

Here too
Attached patch patch (obsolete) — Splinter Review
Attachment #747919 - Attachment is obsolete: true
Attachment #747919 - Flags: review?(Ms2ger)
Attachment #747928 - Flags: review?(Ms2ger)
Once you know window and doc are not null, why not just call createComment on the doc?
Attached patch patchSplinter Review
green on try
Attachment #747928 - Attachment is obsolete: true
Attachment #747928 - Flags: review?(Ms2ger)
Attachment #748022 - Flags: review?(Ms2ger)
Summary: Comment should be consructable → Comment should be constructable
Comment on attachment 748022 [details] [diff] [review]
patch

Review of attachment 748022 [details] [diff] [review]:
-----------------------------------------------------------------

lgtm
Attachment #748022 - Flags: review?(Ms2ger) → review+
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/3411817d911f
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla24
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: