 #   data-pwnfx-refresh-method: the HTTP method of AJAX request (default: POST)
 #   data-pwnfx-refresh-ms: delay between a change on the source element and
 #                          AJAX refresh requests (default: 200ms)
-#   data-pwnfx-refresh-target: set to the value of data-pwnfx-refresh on the
-#                              element populated with the AJAX response
+#   data-pwnfx-refresh-target: a space-separated list of identifiers, one of which
+#       should match the value of data-pwnfx-refresh; set on the element
+#       populated with the AJAX response
 class PwnFxRefresh
   constructor: (element, identifier, scopeId) ->
-    targetSelector = "[data-pwnfx-refresh-target=\"#{identifier}\"]"
+    targetSelector = "[data-pwnfx-refresh-target~=\"#{identifier}\"]"
     xhrUrl = element.getAttribute('data-pwnfx-refresh-url')
     xhrMethod = element.getAttribute('data-pwnfx-refresh-method') || 'POST'
     xhrForm = PwnFx.parentForm element

#       beforebegin, afterbegin, beforeend, afterend; defaults to beforeend
#   data-pwnfx-render-randomize: regexp pattern whose matches will be replaced
#       with a random string; useful for generating unique IDs
#   data-pwnfx-render-target: set on the element(s) receiving the rendered HTML;
#       set to the identifier in data-pwnfx-render
#   data-pwnfx-render-source: set to the identifier in data-pwnfx-render, on the
#       <script> tag containing the source HTML
class PwnFxRender
  constructor: (element, identifier, scopeId) ->
    sourceSelector = "script[data-pwnfx-render-source=\"#{identifier}\"]"
    targetSelector = "[data-pwnfx-render-target=\"#{identifier}\"]"
    insertionPoint = element.getAttribute('data-pwnfx-render-where') ||
                     'beforeend'
    randomizedPatten = element.getAttribute('data-pwnfx-render-randomize')

#
# Attributes:
#   data-pwnfx-remove: an identifier connecting the elements to be removed
#   data-pwnfx-remove-target: a space-separated list of identifiers, one of which
#       should match the value of data-pwnfx-remove; set on elements that will
#       be removed when the element is clicked
class PwnFxRemove
  constructor: (element, identifier, scopeId) ->
    targetSelector = "[data-pwnfx-remove-target~=\"#{identifier}\"]"

    onClick = (event) ->
      scope = PwnFx.resolveScope scopeId, element
