'Handle object nesting before content
:py:class:`JSObject` represents JavaScript language constructs. For
constructs that are nestable, this method will build up a stack of the
nesting heirarchy so that it can be later de-nested correctly, in
:py:meth:`after_content`.
For constructs that aren\'t nestable, the stack is bypassed, and instead
only the most recent object is tracked. This object prefix name will be
removed with :py:meth:`after_content`.
The following keys are used in ``self.env.ref_context``:
js:objects
Stores the object prefix history. With each nested element, we
add the object prefix to this list. When we exit that object\'s
nesting level, :py:meth:`after_content` is triggered and the
prefix is removed from the end of the list.
js:object
Current object prefix. This should generally reflect the last
element in the prefix history'

def before_content(self):

    prefix = None
    if self.names:
        (obj_name, obj_name_prefix) = self.names.pop()
        prefix = (obj_name_prefix.strip('.') if obj_name_prefix else None)
        if self.allow_nesting:
            prefix = obj_name
    if prefix:
        self.env.ref_context['js:object'] = prefix
        if self.allow_nesting:
            objects = self.env.ref_context.setdefault('js:objects', [])
            objects.append(prefix)
