Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

$rootElement click handler traverses above all parents without finding root html element #1060

@bkc

Description

@bkc

New in 1.0.0, when clicking a button embedded in a template, firebug throws this in firefox 13:

elm[0] is undefined
http://code.angularjs.org/1.0.0/angular-1.0.0.js
Line 5356

It looks like this comparison fails to match:

if (elm[0] === $rootElement[0]) return;

then on the next loop elm = []

adding a breakpoint at row 5356, elm is the following elements

button.btn
div.controls
div.control-group
div.span2
div.row
div.tabbable
div.ng-scope

Therefore it appears that div.ng-scope has no parent.

The actual parent of div.tabbable is a div with ng-form. But that div is a fragment loaded into the templateCache using this code

sfiTemplateLoader = angular.module('SFI.template-loader', [])

sfiTemplateLoader.directive 'sfiTemplateLoader', ($templateCache, $rootScope) ->
    return (scope, element, attrs) ->
    options = {}
    mydiv = $('<div />')
    templates = attrs.templates.split(' ')
    loaded_template_count = 0

    for template_path in templates 
        console.log "loading template file", template_path

        mydiv.load template_path, () ->
            # on callback, 'this' is the loaded dom element
            $(this).find('*[template-container]').each (index, element) ->
                template_name = $(element).attr('template-container')
                if template_name
                    html_data = $(element).clone().wrap('<div>').parent().html()      
                    $templateCache.put template_name, html_data
                    console.log('loaded template', template_name)

            loaded_template_count += 1
            if loaded_template_count >= templates.length
                $rootScope.$apply () ->
                    $rootScope.$broadcast 'sfiTemplateLoader', 
                        status:'loaded'

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions