Skip to content

css hook registration consumes too much memory when used with frameworks polluting object prototype #541

Closed
@nonmanifold

Description

@nonmanifold

When Velocity is used with Ember's liquid-fire, due to prototype containing getters, CSS.Hooks.registered receive lots keys whose names contain Ember's getter funtcion definition
So it's better to add hasOwnProperty check:

/* Hook registration. */
for (rootProperty in CSS.Hooks.templates) {
    hookTemplate = CSS.Hooks.templates[rootProperty];
    hookNames = hookTemplate[0].split(" ");

    for (var i in hookNames) {
        if(!hookNames.hasOwnProperty(i)){
          break;
        }
        var fullHookName = rootProperty + hookNames[i],
            hookPosition = i;

        /* For each hook, register its full name (e.g. textShadowBlur) with its root property (e.g. textShadow)
           and the hook's position in its template's default value string. */
        CSS.Hooks.registered[fullHookName] = [ rootProperty, hookPosition ];
    }
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions