Opened 11 years ago

Closed 11 years ago

#10099 closed Bug (fixed)

element.createFromHtml gives error on IE7/8 when adding HTML5 Section tag

Reported by: Stephan Owned by:
Priority: Normal Milestone:
Component: Core : Selection Version: 4.0.1
Keywords: IE7 IE8 Cc: stephan@…

Description

The execution of the code

   editor.insertElement(htmlElement);

gives errors in Internet Explorer Version 8. The code works perfect in Mozilla, but it gives the following error on IE8: " The object doesn´t accept this property or attribute."

This happens on line 269 char 69 of the min version of the javascript file ckeditor.js downloaded 12/02/2013 from the website.

I´ve been searching already for a while. and found that it has something to do with the following function: m=b.getName().

regards Stephan

Change History (8)

comment:1 Changed 11 years ago by Stephan

Cc: stephan@… added

comment:2 Changed 11 years ago by Stephan

Summary: editor.insertElement gives error on IE8 (.getName() not supported?)editor.insertElement gives error on IE7/8 (.getName() not supported?)

I was looking around a little more in the history of tickets, and i found the problem i think. I was trying to insert a html5 tag: "section". This tag isn´t supported yet? because with a span everything is working well? I´m searching now if this is a bug or if i forget to enable a setting?

Version 0, edited 11 years ago by Stephan (next)

comment:3 Changed 11 years ago by Stephan

I have found another part of problem, at least i think so because my error has changed. I made a stupid mistake by closing my head tag withing my body tag..

The error is now on the method .getFirst()

   var a=new CKEDITOR.dom.element("div",c);a.setHtml(b);return a.getFirst()

And that error comes from calling the createFromHtml function. That is the line before the orignal error that was caused by the function insertElement().

All ideas are welcome, If you like to test the issue try the folowing:

   (CKEDITOR.dom.element.createFromHtml( "<section></section>")).getName();

comment:4 Changed 11 years ago by Stephan

Summary: editor.insertElement gives error on IE7/8 (.getName() not supported?)element.createFromHtml gives error on IE7/8 when adding HTML5 Section tag

comment:5 Changed 11 years ago by Stephan

The problem is within the <IE9 support build in the createFromHtml function.

but I have a work around:

var newElement = new CKEDITOR.dom.element('section');
newElement.setAttributes({'class': 'x'});
newElement.setText("test text");
editor.insertElement(newElement);

Still i think it is a bug that i can't insert html5 directly but with this work around, at least i can go on.

Last edited 11 years ago by Stephan (previous) (diff)

comment:6 Changed 11 years ago by Jakub Ś

Keywords: IE7 IE8 added; Internet Explorer getName javacript bug removed
Status: newconfirmed
  1. As it is probably known IE8 or IE7 don't support HTML5 tags by default. This can be checked with - http://html5test.com/
  2. There is a trick to bypass it - html5 shim e.g. http://en.wikipedia.org/wiki/HTML5_Shiv and in very simple form http://www.codeproject.com/Articles/366272/How-to-Get-IE8-to-Support-HTML5-Tags-and-Web-Fonts.

CKEditor uses something very similar to enable HTML5 in IE7-8 but it must be turned on by developer. Method createFromHtml has two arguments: html and document. In order to activate HTML5 shim user should pass editor.document to the method. Taking all into account the below should work:

var editor = CKEDITOR.replace( 'editor1', {} );

editor.on('instanceReady', function(evt){								
	var el = CKEDITOR.dom.element.createFromHtml( "<section>test</section>", editor.document);				
	alert(el.getName());
});

BUT IT DOESN'T
Method createFromHtml returns that getFirst is not supported by this object. This is probably not element but empty object gets created.

Problem can be reproduced from CKEditor 4 beta in IE7-8

comment:7 Changed 11 years ago by Piotrek Koszuliński

CKEditor uses something very similar to enable HTML5 in IE7-8 but it must be turned on by developer. Method createFromHtml has two arguments: html and document. In order to activate HTML5 shim user should pass editor.document to the method. Taking all into account the below should work:

It's not fully correct. HTML5 shim is executed in framed editor's document and works there. But this shim enables HTML5 element only in this document, not in CKEDITOR.document.

Additionally, all elements should be created in documents in wich they will be used. Otherwise old IEs may throw permission denied errors.

When both these points are satisfied HTML5 elements should be successfully created in framed editor's document. But they are not... so something is wrong.

comment:8 Changed 11 years ago by Piotrek Koszuliński

Resolution: fixed
Status: confirmedclosed

This issue is fixed on #9764 which will soon land on major.

Note: See TracTickets for help on using tickets.
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy