473,666 Members | 2,278 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Overriding .textContent of BR elements

In my Firefox 1.5 (on Win XP Pro) a <BR>
element's .textContent returns the empty string.
I have no idea why they (W3C) construed this to
be reasonable, but it was contested, and denied
here:
https://bugzilla.mozilla.org/show_bug.cgi?id=316063

Boris suggests doing something else to get what
I believe most users are really after, but doesn't
say what. Here's a possible approach, with initial
tests working in my FF1.5:

HTMLBRElement.p rototype.__defi neGetter__("inn erText",
function() {return "\n";});

Node.prototype. __defineGetter_ _("innerText" ,
function() {
if (!this.firstChi ld) return this.textConten t;
s=this.firstChi ld;
var res=s.innerText ;
while (s=s.nextSiblin g) res+=s.innerTex t;
return res; });
However, it would be FFFFAAAAAAARRRR nicer
to simply redefine .textContent on the
HTMLBRElement.p rototype and not muck about
with innerText, all on account of the <BRelement
adhering to a standard (whose reasonableness
on this point escapes me). However, the following
line is ignored as far as I can tell - any ideas?:

HTMLBRElement.p rototype.__defi neGetter__("tex tContent",
function() {return "\n";});
Thanks,
Csaba Gabor from Vienna
Oct 11 '08 #1
3 3188
On Oct 11, 11:46*am, Csaba Gabor <dans...@gmail. comwrote:
In my Firefox 1.5 (on Win XP Pro) a <BR>
element's .textContent returns the empty string.
And what more did you expect it to return?
Oct 11 '08 #2
Csaba Gabor wrote:
In my Firefox 1.5 (on Win XP Pro) a <BRelement's .textContent returns
the empty string.
JFYI: Firefox 3.0.3 is the currently stable version. The 1.5 branch reached
its end of life on 2007-05-30 CE with the release of Firefox 1.5.0.12, and
2.0 will in mid of 2008-12 CE.

<http://en.wikipedia.or g/wiki/Mozilla_Firefox #Release_histor y>
I have no idea why they (W3C) construed this to be reasonable,
,-<http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#Node3-textContent>
|
| This attribute returns the text content of this node and its descendants.
| [...]
| Node type Content
| --------------------------------------------------------------------------
| ELEMENT_NODE, concatenation of the textContent attribute
^^^^^^^^^^^^
| ATTRIBUTE_NODE, value of every child node, excluding COMMENT_NODE
| ENTITY_NODE, and PROCESSING_INST RUCTION_NODE nodes.
| ENTITY_REFERENC E_NODE, This is the empty string if the node
^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^ ^^^^^^
| DOCUMENT_FRAGME NT_NODE has no children.
^^^^^^^^^^^^^^^ ^
but it was contested, and denied here:
https://bugzilla.mozilla.org/show_bug.cgi?id=316063

Boris suggests doing something else to get what I believe most users are
really after, but doesn't say what. Here's a possible approach, with
initial tests working in my FF1.5: [...]
..oO(*yawn* Why, is it April 1 again, already?)

The content model of BR/br elements is EMPTY. (To make that more clear
to you: That means it is like a born eunuch; it has no and can not have
[natural] children. [Well, you asked for it.])

If you want to insert an element node or text node *before* or *after* a
BR/br element, just do so:

br.parentNode.i nsertBefore(foo , br);

or

br.parentNode.i nsertBefore(foo , br.nextSibling) ;
HTH

PointedEars
--
var bugRiddenCrashP ronePieceOfJunk = (
navigator.userA gent.indexOf('M SIE 5') != -1
&& navigator.userA gent.indexOf('M ac') != -1
) // Plone, register_functi on.js:16
Oct 11 '08 #3
On 2008-10-11 17:46, Csaba Gabor wrote:
In my Firefox 1.5 (on Win XP Pro) a <BR>
FF 1.5 really shouldn't be used anymore, except for compatibility
testing. I would understand version 2.x (some people can't run 3.x
because of missing libraries), but 1.5 is ancient.
element's .textContent returns the empty string.
I have no idea why they (W3C) construed this to
be reasonable, but it was contested, and denied
here:
https://bugzilla.mozilla.org/show_bug.cgi?id=316063
After reading that bug report, and the specs, it looks like that's the
correct and expected behavior. Inconvenient, maybe, but at least it's
consistent.
Boris suggests doing something else to get what
I believe most users are really after, but doesn't
say what.
(for reference)
| Comment #5 From Boris Zbarsky:
| [..] If you want an actual serialization, instead of just the
| textContent, you need to use something else.

I suppose he was talking about something similar to what you've done
with "innerText" .
HTMLBRElement.p rototype.__defi neGetter__("inn erText",
function() {return "\n";});
Using "innerText" as a getter name is a dubious choice for Firefox.
AFAIK, they still haven't implemented innerText in their DOM
implementation (in contrast to innerHTML), but they might do so in the
future, and then you'll get errors. You should also be aware that the
getter/setter behavior has changed in more recent versions of Firefox:

| Prior to Firefox 3.0, getter and setter are not supported for DOM
| Elements. Older versions of Firefox silently fail. If exceptions are
| needed for those, changing the prototype of HTMLElement
| (HTMLElement.pr ototype.__defin e[SG]etter__) and throwing an
| exception is a workaround.
| With Firefox 3.0, defining getter or setter on an already-defined
| property will throw an exception. The property has to be deleted
| beforehand, what is not the case for older versions of Firefox.

<http://preview.tinyurl .com/4wk75y>
Thanks,
Csaba Gabor from Vienna
Greetings to Vienna,
- Conrad
Oct 11 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
3788
by: Andrew Durdin | last post by:
In Python, you can override the behaviour of most operators for a class, by defining __add__, __gt__, and the other special object methods. I noticed that, although there are special methods for most operators, they are conspicuously absent for the logical "or" and "and". I'm guessing that the reason for this is that these operators short-circuit if their first operand answers the whole question? Would it be possible to allow...
3
4183
by: Ali Eghtebas | last post by:
Hi, I have 3 questions regarding the code below: 1) Why can't I trap the KEYDOWN while I can trap KEYUP? 2) Is it correct that I use Return True within the IF-Statement? (I've already read the documentation but it is rather hard to understand so please don't refer to it :) 3) Many examples in the newsgroups use Return MyBase.ProcessKeyPreview(m) as the last code line while I have used Return MyBase.ProcessKeyEventArgs(m)
0
5750
by: Ian | last post by:
I've got this problem with overriding attributes on an inheritance chain where the XmlSerializer is concerned. For example: public class A { private string aWord = String.Empty(); public virtual string Word { get { return aWord; } set { aWord = value; } }
3
1548
by: Amin Sobati | last post by:
Hi, I have two classes. Class2 inhertis Class1: ----------------------------- Public Class Class1 Public Overridable Sub MySub() End Sub End Class Public Class Class2
38
3468
by: Luke Matuszewski | last post by:
Welcome I have read the in the faq from jibbering about the generic DynWrite, but i also realized that is uses only innerHTML feature of HTML objects. (1) Is there a DOM function which is very similar to innerHTML property eg. (my guess) setInnerNodeAsText or sth... ? I want to write function which will be dynamically updateing some of my select boxes. My question is: (2.1) Can i use innerHTML property of SELECT (or even incorporate
5
1645
by: Dave Cullen | last post by:
I have a program that reads a delimited text file and splits the input string into string array elements: Dim Data(41) as String 'read semicolon delimited fields into string array Data = SrRead.ReadLine().Split(";".ToCharArray) I expect up to 40 elements to be read. But if the input data string has less than that and I try to access Data(40) I get a
2
9529
by: Srinivasa | last post by:
Hai, I am new to this group. But not to Javascript. I have a problam with innerText in FireFox. I have the code as below. -- var inputArea = document.getElementById("rtsText"); var outputArea = document.getElementById("uniText"); outputArea.innerText = transformInput(inputArea.value); -- I have two elements, a textarea in which user entered RTS text, and a div tag in which the converted Unicode text will be place using
10
105177
by: r035198x | last post by:
The Object class has five non final methods namely equals, hashCode, toString, clone, and finalize. These were designed to be overridden according to specific general contracts. Other classes that make use of these methods assume that the methods obey these contracts so it is necessary to ensure that if your classes override these methods, they do so correctly. In this article I'll take a look at the equals and hashCode methods. ...
1
3987
by: yawnmoth | last post by:
What's the difference between the DOMNode proprties of nodeValue and textContent?
0
8440
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8866
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8781
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8550
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5662
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4193
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2769
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2006
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1769
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.