signalpoint / DrupalGap

An application development kit for Drupal websites.
https://www.drupalgap.org
GNU General Public License v2.0
232 stars 185 forks source link

Prefix and suffix renders twice #1036

Open signalpoint opened 3 years ago

signalpoint commented 3 years ago

If you are using a Bucket, and then try to use a render element that contains a Bucket, the prefix and suffix will be rendered twice.

var bucketContent = {
  _prefix: '<div class="foo">',
  _suffix: '</div>',
  stuff: {
    _theme: 'bucket',
    _attributes: {
      id: 'my-bucket'
    },
    /* ... */
  }
};
fill(bucketContent);

You'll end up with html like this:

<div class="foo">
  <div class="foo">
    <div id="my-bucket">...</div>
  </div>
</div>

This may be a problem with dg.render() itself and not limited to just the Bucket widget.

The workaround is to use _markup instead of _theme:

var bucketContent = {
  _prefix: '<div class="foo">',
  _suffix: '</div>',
  stuff: {
    _markup: dg.theme('bucket', {       
       _attributes: {
          id: 'my-bucket'
        },
        /* ... */
    })
  }
};
fill(bucketContent);