src/web-component-refs.js
function collectRefs() {
  // check if there's a shadow root in the element
  if (typeof this.shadowRoot === 'undefined') {
    throw new Error('You must create a shadowRoot on the element');
  }

  // create refs base object
  this.refs = {};

  var refsList = this.shadowRoot.querySelectorAll('[ref]');

  // collect refs if any
  if (refsList.length > 0) {
    var refsArray = _toArray(refsList);

    refsArray.map(_assignRef.bind(this));
  }

  // observe added and removed child nodes
  var refsMutationObserver = new MutationObserver(_handleMutations.bind(this));

  refsMutationObserver.observe(this.shadowRoot, {
    childList: true,
    subtree: true
  });
}
function collectRefs() {
  // check if there's a shadow root in the element
  if (typeof this.shadowRoot === 'undefined') {
    throw new Error('You must create a shadowRoot on the element');
  }

  // create refs base object
  this.refs = {};

  var refsList = this.shadowRoot.querySelectorAll('[ref]');

  // collect refs if any
  if (refsList.length > 0) {
    var refsArray = _toArray(refsList);

    refsArray.map(_assignRef.bind(this));
  }

  // observe added and removed child nodes
  var refsMutationObserver = new MutationObserver(_handleMutations.bind(this));

  refsMutationObserver.observe(this.shadowRoot, {
    childList: true,
    subtree: true
  });
}
function collectRefs ( ) { // check if there's a shadow root in the element if ( typeof this . shadowRoot === 'undefined' ) { throw new Error ( 'You must create a shadowRoot on the element' ) ; } // create refs base object this . refs = { } ; var refsList = this . shadowRoot . querySelectorAll ( '[ref]' ) ; // collect refs if any if ( refsList . length > 0 ) { var refsArray = _toArray ( refsList ) ; refsArray . map ( _assignRef . bind ( this ) ) ; } // observe added and removed child nodes var refsMutationObserver = new MutationObserver ( _handleMutations . bind ( this ) ) ; refsMutationObserver . observe ( this . shadowRoot , { childList : true , subtree : true } ) ; }
Inspects shadow root and creates a refs object in a custom element
@method collectRefs
@returns {undefined}
Inspects shadow root and creates a refs object in a custom element