Closed Bug 460568 Opened 16 years ago Closed 16 years ago

removeAttribute('contenteditable') doesn't work fine

Categories

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

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: masayuki, Assigned: masayuki)

References

Details

Attachments

(2 files, 1 obsolete file)

Attached file testcase
removeAttribute('contenteditable') doesn't work fine.

The editable element should be changed to normal contents, however, the inner elements are not reset the editable state.

See the attached testcase, you cannot focus to the anchor even if the contenteditable attribute was removed.
Attached patch Patch v1.0 (obsolete) — Splinter Review
ChangeEditableState should not be called before nsGenericHTMLElementBase::UnsetAttr. Because it's looking the attr value for its result. But it will be updated by nsGenericHTMLElementBase::UnsetAttr.
Attachment #343704 - Flags: superreview?(peterv)
Attachment #343704 - Flags: review?(peterv)
Comment on attachment 343704 [details] [diff] [review]
Patch v1.0

I'd do:

  PRBool contentEditable = PR_FALSE;
  PRInt32 contentEditableChange;

  // Check for event handlers
  if (aNameSpaceID == kNameSpaceID_None) {
    if (aAttribute == nsGkAtoms::contenteditable) {
      contentEditable = PR_TRUE;
      contentEditableChange = GetContentEditableValue() == eTrue ? -1 : 0;
    }
    else if (nsContentUtils::IsEventAttributeName(aAttribute,
                                                  EventNameType_HTML)) {
      nsCOMPtr<nsIEventListenerManager> manager;
      GetListenerManager(PR_FALSE, getter_AddRefs(manager));

      if (manager) {
        manager->RemoveScriptEventListener(aAttribute);
      }
    }
  }

  nsresult rv = nsGenericHTMLElementBase::UnsetAttr(aNameSpaceID, aAttribute,
                                                    aNotify);
  NS_ENSURE_SUCCESS(rv, rv);

  if (contentEditable) {
    ChangeEditableState(contentEditableChange);
  }

  return NS_OK;

With that, r/sr=me.
Attachment #343704 - Flags: superreview?(peterv)
Attachment #343704 - Flags: superreview+
Attachment #343704 - Flags: review?(peterv)
Attachment #343704 - Flags: review+
Attached patch Patch v1.1Splinter Review
Attachment #343704 - Attachment is obsolete: true
Attachment #344749 - Flags: superreview+
Attachment #344749 - Flags: review+
checked-in.
Status: ASSIGNED → RESOLVED
Closed: 16 years ago
Resolution: --- → FIXED
Component: Content → DOM
QA Contact: content → general
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: