import { PROTECTED_KEYS } from '../globals/protected-keys.global' ; import { createOffscreenContext } from '../utils/context.utils' ; export function applySetterPatches ( context ) { Object . keys ( context . prototype ) . filter ( member => PROTECTED_KEYS . indexOf ( member ) < 0 ) . map ( member => ( { member , descriptor : Object . getOwnPropertyDescriptor ( context . prototype , member ) } ) ) . filter ( ( { descriptor } ) => descriptor . set ) . forEach ( ( { member , descriptor } ) => { const original = descriptor ; Object . defineProperty ( context . prototype , member , { get : function ( ) { if ( this . canvas . __skipFilterPatch ) { return original . get . call ( this ) ; } return this . canvas . __currentPathMirror [ member ] ; } , set : function ( value ) { if ( this . canvas . __skipFilterPatch ) { return original . set . call ( this , value ) ; } if ( ! this . canvas . __currentPathMirror ) { this . canvas . __currentPathMirror = createOffscreenContext ( this ) ; } this . canvas . __currentPathMirror [ member ] = value ; } } ) ; } ) ; }