Skip to content

Instantly share code, notes, and snippets.

@Oleksii909
Created November 14, 2020 09:51
Show Gist options
  • Save Oleksii909/8d2767d71c379583a8343f1168476921 to your computer and use it in GitHub Desktop.
Save Oleksii909/8d2767d71c379583a8343f1168476921 to your computer and use it in GitHub Desktop.
<?php
$js_match_field_element_attributes = <<<JS
function () {
var expectations = $expected_field_attributes_json;
var entityCollection = Drupal.quickedit.collections.entities;
var entityModel = entityCollection.get('$entity_page_id');
return entityModel.get('fields').reduce(function (result, fieldModel) {
var fieldID = fieldModel.get('fieldID');
var element = fieldModel.get('el');
var matches = element.webkitMatchesSelector(expectations[fieldID]);
result[fieldID] = matches ? matches : element.outerHTML;
return result;
}, {});
}()
JS;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment