Transform JavaScript apply into correct parent node.