Skip to content
This repository was archived by the owner on Sep 20, 2019. It is now read-only.
This repository was archived by the owner on Sep 20, 2019. It is now read-only.

contenteditable attribute of a div hanging with document.execCommand and insertunorderedlist #906

@halloweenman

Description

@halloweenman

Description

I'm writing a very basic WYSIWYG rich editor using contenteditable attribute of a div but experiencing issues with document.execCommand and executing the command insertunorderedlist. If you select and highlight the text you want to insert an unordered list and click insert button then it either fails to work correctly using Chrome (latest version) or if using Safari (latest version High Sierra), just hangs. If you try this outside of webcomponents / Polymer (plain old html and javascript) it works fine. Here's the code:

<link rel="import" href="../../bower_components/polymer/polymer-element.html">

<dom-module id="polymerbasic-app">
  <template>
    <style>
      :host {
        display: block;
      }
    </style>

    <button on-click="_insertunorderedlist" type="button">Insert Unordered List</button>

    <div id="textBox" contenteditable="true">
      Bullet One
      <br> Bullet Two
      <br> Bullet Three
    </div>
  </template>

  <script>
    /**
     * @customElement
     * @polymer
     */
    class PolymerbasicApp extends Polymer.Element {
      static get is() { return 'polymerbasic-app'; }
      static get properties() {
        return {
          prop1: {
            type: String,
            value: 'polymerbasic-app'
          }
        };

      }
      _insertunorderedlist() {
        document.execCommand("insertunorderedlist", false, null); this.$.textBox.focus();
      }

    }

    window.customElements.define(PolymerbasicApp.is, PolymerbasicApp);
  </script>
</dom-module>

Steps to Reproduce

Select and highlight Bullet One, Bullet Two, and Bullet Three text and click on insert button using Safari or other browser.

Expected Results

html Unordered list.

Actual Results

Hangs, or does not behave correctly.

Browsers Affected

  • [ x] Chrome
  • [ x] Firefox
  • [ x] Edge
  • [ x] Safari 9
  • [ x] Safari 8
  • [ x] IE 11

Versions

  • Polymer: v1.11.3
  • webcomponents: v1.1.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions