@diosmosis opened this Pull Request on October 8th 2021 Member

Description:

This PR is based off of #18106

I looked into migrating the piwikApi service, but since it's API is dependent on the angular library, it seemed too much work to create a different implementation, then an adapter for existing angularjs code. Instead I opted to expose the jqXHR object from jQuery in AjaxHelper, which gives it a promise API. New code in Vue will use this API, old jquery specific code can use the callback version of ajaxHelper, and old angularjs code can use piwikApi until Matomo 5. This seemed like the simplest solution and should have no BC breaks.

I also looked at using browser native fetch() function w/ a polyfill (using github's fetch polyfill) in AjaxHelper so we wouldn't have to use jQuery. The API, unfortunately, is too different from jQuery's, so it would be very difficult to provide BC. By Matomo 5, it could be possible to switch the implementation away from jQuery if desired.

New Vue code should use ajaxHelper's promise API.

DOM Sanitization

Also added a new library to sanitize HTML when migrating uses of ng-bind-html since Vue doesn't include one by deafult. Using https://github.com/cure53/DOMPurify, tested with ExampleVue, and it works. ng-bind-html/v-html should ideally not be used, but that would be a large undertaking.

image

image

Note: jump in size is due to dom sanitizer. Unavoidable, but when angularjs is removed, the file size will go down.

Review

@diosmosis commented on October 10th 2021 Member

Also migrated piwik-helper.spec.js + renamed piwik => matomo in as many places as possible in new code.

@diosmosis commented on October 10th 2021 Member

Adding DOM sanitizer library as well so future PRs can just use it.

This Pull Request was closed on October 13th 2021
Powered by GitHub Issue Mirror