<commit_before>import events from '../../../src/lifecycle/events';
import helpers from '../../lib/helpers';

var CustomEvent = window.CustomEvent;

describe('lifecycle/events', function () {
  var supportsShadowRoot = 'createShadowRoot' in window.HTMLElement.prototype;

  /* jshint expr: true */
  supportsShadowRoot && describe('shadow dom events', function () {
    var div, shr1, shr2, triggered;

    function assertDelegation (btn) {
      return function (elem, evnt, curr) {
        triggered = true;
        expect(elem).to.equal(div);
        expect(curr).to.equal(btn);
      }
    }

    function dispatchClick (btn) {
      btn.dispatchEvent(new CustomEvent('click', { bubbles: true }));
    }

    function assertDispatchClick (delegateSelector, btnId) {
      var btn = div.querySelector('* /deep/ #' + btnId);
      events(div, { ['click ' + delegateSelector + ' button']: assertDelegation(btn) });
      dispatchClick(btn);
      expect(triggered).to.equal(true);
    }

    beforeEach(function () {
      triggered = false;

      // The main component element with a light DOM button.
      div = document.createElement('div');
      div.innerHTML = `
        <button id="in-light-content"></button>
      `;<commit_msg>Add missing semi-colon.<commit_after>import events from '../../../src/lifecycle/events';
import helpers from '../../lib/helpers';

var CustomEvent = window.CustomEvent;

describe('lifecycle/events', function () {
  var supportsShadowRoot = 'createShadowRoot' in window.HTMLElement.prototype;

  /* jshint expr: true */
  supportsShadowRoot && describe('shadow dom events', function () {
    var div, shr1, shr2, triggered;

    function assertDelegation (btn) {
      return function (elem, evnt, curr) {
        triggered = true;
        expect(elem).to.equal(div);
        expect(curr).to.equal(btn);
      };
    }

    function dispatchClick (btn) {
      btn.dispatchEvent(new CustomEvent('click', { bubbles: true }));
    }

    function assertDispatchClick (delegateSelector, btnId) {
      var btn = div.querySelector('* /deep/ #' + btnId);
      events(div, { ['click ' + delegateSelector + ' button']: assertDelegation(btn) });
      dispatchClick(btn);
      expect(triggered).to.equal(true);
    }

    beforeEach(function () {
      triggered = false;

      // The main component element with a light DOM button.
      div = document.createElement('div');
      div.innerHTML = `
        <button id="in-light-content"></button>
      `;
{'fraction_non_alphanumeric': 0.1450381679389313, 'fraction_numerical': 0.0016070711128967456, 'mean_word_length': 2.971291866028708, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7461424', 'n_tokens_mistral': 713, 'n_tokens_neox': 715, 'n_words': 168}