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

ng-include's onload generates errors with SVG elements in some browsers #12493

Closed
@mcweiss

Description

@mcweiss

If use ng-include on an SVG element and include an onload handler errors are thrown in Internet Explorer 11 (and in our selenium test runner - chutzpah, which seems to use phantomjs). This is a problem when developers use IE and it breaks our automated unit tests during builds.

It appears that SVG elements also define an attribute called "onload", which conflicts with the angular version of onload. In IE it actually attempts to call my function itself (not via angular) which results in an error.

SCRIPT5009: 'myOnLoadFunction' is undefined

For example

<svg>
<g ng-include="content.svg" onload="myload()"></g>
</svg>

will result in 2 calls to something call myload(). Once by IE, which results in an error in the console since window.myload() doesn't exist. Next angular will call scope.myload(), which is what I intended.

A workaround was to create a noop windows.myload() function. This gives something for IE to call, and prevents the error. There should be way to define an onload expression w/o interfering with the SVG onload eventing. Maybe an alternate name? (ng-onload? data-onload?)

Demo (IE 11 with console open):
http://plnkr.co/edit/OdgOanXOgLoCXDxpI5yN?p=info

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions