Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

feat(onProperty): fix #875, can disable patch specified onProperties #877

Merged
merged 6 commits into from
Aug 23, 2017

Conversation

JiaLiPassion
Copy link
Collaborator

fix #875.

can disable patch specified onProperties,for example,
if you want to disable window.onmessage and HTMLElement.prototype.onclick from zone.js patching,
you can do like this.

 <script>
    __Zone_ignore_on_properties = [
      {
        target: window,
        ignoreProperties: ['message']
      }, {
        target: HTMLElement.prototype,
        ignoreProperties: ['click']
      }
    ];
  </script>
  <script src="../dist/zone.js"></script>

export function propertyDescriptorPatch(api: _ZonePrivate, _global: any) {
if (isNode && !isMix) {
return;
}

const supportsWebSocket = typeof WebSocket !== 'undefined';
if (canPatchViaPropertyDescriptor()) {
const ignoreProperties: IgnoreProperty[] = _global.__Zone_ignore_on_properties;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we turn this into our own module so that it is consistent with the rest of the system?

Copy link
Collaborator Author

@JiaLiPassion JiaLiPassion Aug 23, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mhevery , currently propertyDescriptorPatch is only be called from here, it is already in our module system.

Zone.__load_patch('on_property', (global: any, Zone: ZoneType, api: _ZonePrivate) => {
  propertyDescriptorPatch(api, global);
  propertyPatch();
  registerElementPatch(global);
});

and the _global is also from our own module parameter.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So what is the point of having this check?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohh, now I understand. ... :-)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[API] __Zone_disable_RequestAnimationFrame
3 participants