GithubHelp home page GithubHelp logo

taconite's People

Contributors

leeoniya avatar malsup avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

taconite's Issues

Problem with the replace command

Hi Mike, and first let me thank you producing an incredibly useful extension.

I've just upgraded to version 3.64 and hit a problem where my code entered an infinite error loop of 'cannot call method fadein of undefined'. I tracked this down to the fact that the new replace command has split the after and remove into 2 statements and no longer returns anything. I've patched it to just add a return in front of the remove and my code now works, though I'm unsure that this is the correct solution.

Thanks,

Noel

Autodetect Taconite and strings in Ajax

There appears to be a problem when Taconite intercepts all Ajax calls, and the response data from the call is simply text (no html) or poorly formed html.
IE9 will throw a Syntax Error, and Firefox will report either the same or a 'junk after' error. I'm using the latest version of taconite (3.59) and jquery 1.5.2. The issue can be recreated below:

$.get('test.php', function(data) {
    alert(data);
});

And in the test.php file:

<?php
echo 'test';
?> 

Now try the same test but change the test.php file to get a different error :

<?php
echo '<em>Tested</em> again';
?>

I'm not sure if this is the correct way to fix it, but changing line 95 from :

if ((data && data.documentElement && data.documentElement.nodeName != 'parsererror') || typeof data == 'string') {

to :

if (data && data.documentElement && data.documentElement.nodeName != 'parsererror' && ct == 'text/xml') {

seems to fix the problem for me. Actual taconite calls work correctly in all cases.

Disappearing JavaScript

I am using FF version 7.0.1 for Ubuntu Linux.

JavaScript in the XML response is not showing up in the updated HTML. For example, this XML response:

 <replaceContent select='#main'>
    <eval>
    <![CDATA[
    <script type="text/javascript">
            alert("hello");
    </script>
    ]]>
    </eval>
</replaceContent>

Will produce this HTML:

<eval>
<div>

</div>
</eval>

The JavaScript is executed, however, and an alert box is generated. Note that the HTML also contains enclosing DIV tags (not to mention the special EVAL tag!). This is another example of my earlier bug #15. Those DIV tags show up on Windows7 and FF 8 too.

Anyway, why is the JavaScript not showing up in the HTML? I ran more tests and found that the JavaScript is always absent. I have a lot of JavaScript that I am returning and none of it works properly when using taconite. It would help if I could actually see it in the HTML.

jQuery.browser is deprecated

I would be grateful if you would like to update the code so it can work with latest jQuery version since the jQuery.browser is depreceted. Thank you

handleCDATA() has always zero children

The if condition in the handleCDATA function is never triggered because $ch is always zero. The data is appended after the children are assigned to $ch (see lines 324-325).

issue #4 (don't try to parse plain text or html responses) discussion | IE9 support

On line 101 of the library, it performs a test on the data element (which has been determined to be a string) to "decide" whether or not to process the string - or ignore it.

if ( /taconite/.test(data) )
$.taconite(data);

The issue I'm facing (only present in IE9 at this point) is in the case that the string contains html & javascript which contain the word taconite.

When I load my image gallery tool into the DOM - it contains html with additional javascript in it. When one of the javascrpt functions within the code runs - it performs an ajax request and processes the results through $.taconite().

Once the html is loaded into the DOM - the test checks the new string - sees the text "taconite" and so it attempts to process the string. I can see why this needs to be included, but are there any thoughts or ideas on a more robust test (perhaps check the "context" of where the word taconite appears - is it pure javascipt / or html with javascript with it <some_tag></some_tag><script>...taconite...</script>).

jquery 1.9

Please update this so it will work with jquery 1.9

rawData namespacing

currently, taconite-rawdata-notify event fires for every rawData node. the main problem with this is that the callback bound to this event must rely exclusively on data 'type' to determine the purpose/target of the data and since it can fire multiple times for a single ajax request, things get very confusing and ugly.

without becoming too soap-like, namespaces are probably needed and only a single taconite-rawdata-notify event should fire per request. i'm proposing the following amended structure:

<taconite>
    <rawData type="json" namespace="errs">{"code":334,"msg":"abcd"}</rawData>
    <rawData type="json" namespace="errs">{"code":666,"msg":"efgh"}</rawData>
    <rawData type="mustache" name="prod_tpl" namespace="tpls">{{id}}, {{name}}, {{price}}</rawData>
    <rawData type="mustache" name="cntct_tpl" namespace="tpls">{{last_name}}, {{first_name}}</rawData>
</taconite>

rawData nodes will be aggregated by their namespace into one object which will be passed into a single notify event:

{
    errs: [
        {data: Error_ObjA, name: "", type: "json", raw:...}
        {data: Error_ObjB, name: "", type: "json", raw:...}
    ],
    tpls: [
        {data: Template_ObjA, name: "prod_tpl", type: "mustache", raw:...}
        {data: Template_ObjB, name: "cntct_tpl", type: "mustache", raw:...}
    ]
}

nodes lacking a namespace can be grouped into a reserved 'none' or similar property.

i think this provides for a much-improved data-passing API. i'll try to put together a pull request with this implementation in a bit. no harm in breaking (for the better) an unpublished, undocumented beta API.

BUG: empty strings are converted to 0

a code like

<val select="textarea" arg1=""/>

is adding 0 to textarea value.

It might be good idea to check length before converting to string.

so a code at line 262 should look like this

if(v.length){
var n = Number(v);
if (v == n) v = n;
}

instead of this.

var n = Number(v);
if (v == n){v = n;}

https://gist.github.com/936457

Extra div tags added to CDATA content

Hi,
This is a weird bug. It only occurs if the content of the CDATA tag is generated like this:

<replaceContent select='#main'>

<![CDATA[
    howdy
     ]]>

</replaceContent>

The DOM element with id "main" will now contain another div with "howdy" inside of it. This is very annoying!

How do I get rid of that extra div? I want to use CDATA because I need to. I am using it for data more complex than one word "howdy". But I don't want that extra div! Please help.

Incorrect value assigned to Input when using a numeric or empty value

Hi

Affects taconite 3.65 to 3.66.

Since the introduction of 3.65 a bug has occurred. When trying to assign an empty value or a value with a leading 0, taconite will assign a different value. This bug did not occur in 3.64.

HTML to replicate bug

<input id = 'textInput' type = 'text' value = ''/>

XML to replicate bug

<taconite>
<!--Will assign '0' to the input value when the value should be empty -->
<attr select = '#textInput' name = 'value' value =''/>
<!--Will assign '12345' to the input value when the value should be '012345'-->
<attr select = '#textInput' name = 'value' value ='012345'/>
</taconite>

The Fix
Assigning the value to type primitive type Number seems to be causing the issue. I'm unsure why this is done to be honest, surely its better just to assign the value specified in the XML document.
The offending lines causing this issue is between 290 - 295.

/*Replace this */
        if (v !== null) {
            tmp = Number(v);
            if (v == tmp)
                v = tmp;
            a.push(v);
        }
/*With this*/
if (v !== null) a.push(v);

Also lines 303 - 307.

/*Comment these lines out */
           if (v.length) {
                tmp = Number(v);
                if (v == tmp)
                    v = tmp;
            }

Proposed IE Fix

Proposed code modification (line 145):

From:
if( ! xml ) {

To:
if (! ( xml && xml.documentElement) ) {

Reason:
In IE, during a call to pull content (including inline javascript referencing taconite - there is a reason I'm not using taconite to evaluate this code after it has loaded) over AJAX and load it within colorbox - IE would error out (Message: Object required | Line: 150 | Char: 3 | Code: 0). After much debugging - I noticed that taconite was attempting to process the entire html string after it was loaded into the browser.

It would fail this test and convert the string to an object as is expected (starting at line 142):
if (typeof xml == 'string')
xml = convert(xml);

And then error out in IE a few lines down because xml.documentElement is null (line 150):
var root = xml.documentElement.tagName;

Firefox, Safari, Opera and Chrome did not experience this error - however - by adding the simple test in the proposed fix, all browsers work. If required, I can supply an example (as I realize my explanation is quite concise and isolated).

Global events are undocumented and deprecated

In the processDoc function there are some global events which are causing issues with newer versions of jQuery.

$.event.trigger('taconite-begin-notify', [taconiteDoc]);
$.event.trigger('taconite-rawdata-notify', [rawData]);
$.event.trigger('taconite-complete-notify', [xml, !!status, status === true ? null : status]);

Can these be easily changed to be non-global events? I tried the below but get a new error. I'm not clear where these custom events are defined, for example I don't see any calls to 'bind' them to the object so I'm not sure how else I can fix it.

I've tried:

$(taconiteDoc).event.trigger('taconite-begin-notify');
$(rawData).event.trigger('taconite-rawdata-notify');
$(xml).event.trigger('taconite-complete-notify', !!status, status === true ? null : status]);

But get "TypeError: $(...).event is undefined"

enhancement - add a way to return data along with markup

hi Mike,

it would be great to be able to return data along with the xml markup and scripts. the only way to do it now is to rely on some global variable and set it via <eval> (ewww). or parse it out using datafilters in the new ajax pipeline.

perhaps another reserved tag similar to <eval> like <data type=""> (text/csv, application/json, etc) with the parsed object passed to any 'taconite-complete-notify' callbacks.

if i was to get really carried away, i'd add the ability to register parsers into taconite for datatypes you expect to get back, including any custom ones you make up. eg: $.taconite.addDataParser('my/format', function(str){return str;});

i can fork, slap something together and do a pull request. what do you think?

thanks,
Leon

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.