How to use the @polymer/polymer/lib/utils/flattened-nodes-observer.js.FlattenedNodesObserver.getFlattenedNodes function in @polymer/polymer

To help you get started, we’ve selected a few @polymer/polymer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github elmsln / lrnwebcomponents / elements / hax-body / hax-body.js View on Github external
_applyContentEditable(
    status,
    target = this.shadowRoot.querySelector("#body")
  ) {
    let children =
      target.localName === "slot"
        ? wrap(target).assignedNodes({ flatten: true })
        : [];
    // fallback for content nodes if not polymer managed nodes above
    if (children.length === 0) {
      children = FlattenedNodesObserver.getFlattenedNodes(target);
    }
    for (var i = 0, len = children.length; i < len; i++) {
      // we have to tell the browser that primatives are editable
      if (this._HTMLPrimativeTest(children[i])) {
        if (status) {
          children[i].setAttribute("contenteditable", status);
          children[i].setAttribute("data-editable", status);
          if (children[i].querySelectorAll("a").length > 0) {
            let links = children[i].querySelectorAll("a");
            for (var j = 0, len2 = links.length; j < len2; j++) {
              links[j].setAttribute("contenteditable", status);
              links[j].setAttribute("data-editable", status);
              links[j].addEventListener("click", e => {
                e.preventDefault();
                e.stopPropagation();
                e.stopImmediatePropagation();
github elmsln / lrnwebcomponents / elements / hax-body / lib / hax-preview.js View on Github external
}
            this.value[property] = this.activeHaxElement.properties[property];
          }
        }
        var slotsApplied = false;
        for (var prop in props.settings[newValue]) {
          let previewNode = this.previewNode;
          if (
            typeof props.settings[this.formKey][prop].slot !==
              typeof undefined &&
            !slotsApplied
          ) {
            slotsApplied = true;

            // walk through the slots looking for the value of it
            const previewNodeChildren = FlattenedNodesObserver.getFlattenedNodes(
              previewNode
            );
            for (var i in previewNodeChildren) {
              // test for element nodes to be safe
              if (
                typeof previewNodeChildren[i] !== typeof undefined &&
                previewNodeChildren[i].nodeType === 1 &&
                previewNodeChildren[i].slot ===
                  props.settings[this.formKey][prop].slot
              ) {
                if (
                  typeof previewNodeChildren[i].innerHTML !== typeof undefined
                ) {
                  schema.properties[
                    props.settings[this.formKey][prop].slot
                  ].value = previewNodeChildren[i].innerHTML;
github web-padawan / lit-components / test / unit / button.spec.js View on Github external
it('should define button label using light DOM', () => {
    const children = FlattenedNodesObserver.getFlattenedNodes(label);
    expect(children[0].textContent).to.be.equal('Lit ');
    expect(children[1].outerHTML).to.be.equal('<i>Button</i>');
  });
github web-padawan / lit-components / test / unit / checkbox.spec.js View on Github external
it('should define checkbox label using light DOM', () =&gt; {
    const children = FlattenedNodesObserver.getFlattenedNodes(label);
    expect(children[0].textContent).to.be.equal('Lit ');
    expect(children[1].outerHTML).to.be.equal('<i>Checkbox</i>');
  });
github kcmr / code-sample / code-sample.js View on Github external
_getCodeTemplate() {
    const nodes = FlattenedNodesObserver.getFlattenedNodes(this.$.content);
    return [].filter.call(nodes, (node) => node.nodeType === Node.ELEMENT_NODE)[0];
  }
github kcmr / code-sample / src / code-sample.js View on Github external
_getCodeTemplate() {
    const nodes = FlattenedNodesObserver.getFlattenedNodes(this.$.content);
    return [].filter.call(nodes, (node) => node.nodeType === Node.ELEMENT_NODE)[0];
  }